/
wizard.htm
1146 lines (1136 loc) · 64 KB
/
wizard.htm
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<%+header%>
<%
local uci = require("luci.model.uci").cursor()
local net = require "luci.model.network".init()
local fs = require "nixio.fs"
local sys = require "luci.sys"
local ut = require "luci.util"
local uname = nixio.uname()
local ifaces = sys.net:devices()
local ifttyu = nixio.fs.glob("/dev/ttyUSB*")
local ifttyc = nixio.fs.glob("/dev/cdc-wdm*")
local sqm = luci.sys.exec("opkg list-installed | grep -q luci-app-sqm && echo -n '1' || echo -n '0'")
local qos = luci.sys.exec("opkg list-installed | grep -q luci-app-qos && echo -n '1' || echo -n '0'")
menuentry = uci:get("openmptcprouter","settings","menu") or "openmptcprouter"
function device_notvirtual(dev)
if dev:match("^eth.*") or dev:match("^wwan.*") or dev:match("^tun.*") or dev:match("/") then
return true
end
networks = net:get_networks()
for _, iface in ipairs(networks) do
local ifacen = iface:name()
local ifacename = uci:get("network",ifacen,"device")
local ifacetype = uci:get("network",ifacen,"type") or ""
local ifaceproto = uci:get("network",ifacen,"proto") or ""
--if ifacename == dev and (ifacetype == "macvlan" or ifacetype == "bridge" or ifaceproto == "6in4") then
if ifacename == dev and (ifacetype == "macvlan" or ifaceproto == "6in4") then
return false
end
end
return true
end
function splitstring(inputstr, sep)
if inputstr == nil then
return ""
end
if sep == nil then
sep = "%s"
end
local t={}
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
table.insert(t, str)
end
return t
end
alltty = {}
iftty = luci.sys.exec("timeout 1 /usr/bin/mmcli -L")
for listtty in iftty:gmatch("([^\r\n]*)[\r\n]") do
modemid = luci.util.trim(luci.sys.exec("echo '" .. listtty .. "' | awk -F' ' '{print $1}' | awk -F/ '{print $6}'"))
if modemid ~= '' then
modeminfo = luci.sys.exec("timeout 1 /usr/bin/mmcli -m " .. modemid .. " --output-keyvalue")
tty = luci.util.trim(luci.sys.exec("echo '" .. modeminfo .. "' | grep 'modem.generic.device ' | awk -F': ' '{print $2}'"))
table.insert(alltty, tty)
end
end
%>
<script type="text/javascript" src="<%=resource%>/cbi.js?v=git-18.243.49640-2f13420" data-strings="{"path":{"resource":"\/luci-static\/resources","browser":"\/cgi-bin\/luci\/admin\/filebrowser"}}"></script>
<script src="/luci-static/resources/xhr.js?v=git-18.324.48426-65adb4e"></script>
<script>
function jsshowadv() {
if(document.getElementById('showadv').checked){
document.getElementById('advancedsettings').style.display='inline';
} else {
document.getElementById('advancedsettings').style.display='none';
}
}
</script>
<% if stderr and #stderr > 0 then %><pre class="error"><%=pcdata(stderr)%></pre><% end %>
<form class="inline" method="post" action="<%=url('admin/system/' .. menuentry:lower() .. '/wizard_add')%>" enctype="multipart/form-data" onkeydown="return event.key != 'Enter';">
<div class="cbi-map">
<h2 name="content"><%:Wizard%></h2>
<fieldset class="cbi-section" id="server">
<legend><%:Server settings%></legend>
<%
nbserver=0
uci:foreach("openmptcprouter","server", function(s)
nbserver=nbserver+1
end)
if nbserver == 0 then
uci:set("openmptcprouter","vps","server")
end
uci:foreach("openmptcprouter","server", function(s)
servername = s[".name"]
%>
<div class="cbi-section-remove right">
<input type="submit" name="deleteserver.<%=servername%>" value="<%:Delete%>" class="cbi-button" />
<input type="hidden" name="server.<%=servername%>" value="<%=servername%>" />
</div>
<h3><%=servername%></h3>
<div class="cbi-section-node" id="cbi-omr-wizard-<%=servername%>">
<div class="cbi-value" id="<%=servername%>.server_ip" data-depends="[{"enableipv6":"1"}]" data-index="1">
<label class="cbi-value-title" for="server_ip.1"><%:Server IP%></label>
<div class="cbi-value-field">
<input name="<%=servername%>.serverip.ip1" id="<%=servername%>.server_ip.1" placeholder="<%:Server IP%>" class="cbi-input-text" value="<%=uci:get_list("openmptcprouter",servername,"ip")[1]%>" data-optional="false">
<div class="cbi-value-description">
<%:Server IP will be set for proxy and VPN%>
</div>
</div>
</div>
<div class="cbi-value" id="<%=servername%>.server_ipv6" data-depends="[{"enableipv6":"0"}]" data-index="1">
<label class="cbi-value-title" for="server_ip.1"><%:Server IP%></label>
<div class="cbi-value-field">
<input name="<%=servername%>.serverip.ip1" id="<%=servername%>.server_ip.1" placeholder="<%:Primary server IP%>" class="cbi-input-text" value="<%=uci:get_list("openmptcprouter",servername,"ip")[1]%>" data-optional="false">
<input name="<%=servername%>.serverip.ip2" id="<%=servername%>.server_ip.2" placeholder="<%:Secondary server IP%>" class="cbi-input-text" value="<%=uci:get_list("openmptcprouter",servername,"ip")[2]%>" data-optional="false">
<div class="cbi-value-description">
<%:Server IP will be set for proxy and VPN%>
</div>
<div class="cbi-value-description">
<%:A second server's IP can be set for dual IPv4/IPv6 server if WAN IPv6 are set%>
</div>
</div>
</div>
<br />
<div class="cbi-value" data-index="2">
<label class="cbi-value-title"><%:Server username%></label>
<div class="cbi-value-field">
<input type="text" name="<%=servername%>.openmptcprouter_vps_username" placeholder="<%:Server username%>" class="cbi-input-text" value="<%=uci:get("openmptcprouter",servername,"username")%>" data-optional="false">
<br />
<div class="cbi-value-description">
<%:API username to retrieve personnalized settings from the server.%>
</div>
</div>
</div>
<div class="cbi-value" data-index="3">
<label class="cbi-value-title"><%:Server key%></label>
<div class="cbi-value-field">
<input type="text" name="<%=servername%>.openmptcprouter_vps_key" placeholder="<%:Server key%>" class="cbi-input-text" value="<%=uci:get("openmptcprouter",servername,"password")%>" data-optional="false">
<br />
<div class="cbi-value-description">
<%:Key to configure and retrieve others keys from Server and to set server settings from OpenMPTCProuter.%>
</div>
</div>
</div>
<%
if nbserver > 1 then
%>
<br />
<div class="cbi-value" data-index="4">
<label class="cbi-value-title"><%:Set server as master%></label>
<div class="cbi-value-field">
<input class="cbi-input-radio" type="radio" name="master" value="<%=servername%>" <% if uci:get("openmptcprouter",servername,"master") == "1" then %>checked <% end %>/>
<br />
<div class="cbi-value-description">
<%:Only one server can be master, else all servers are set as backup.%>
</div>
</div>
</div>
<%
end
%>
<br />
<div class="cbi-value" data-index="5">
<label class="cbi-value-title"><%:Disable server%></label>
<div class="cbi-value-field">
<input class="cbi-input-radio" type="checkbox" name="<%=servername%>.openmptcprouter_vps_disabled" value="1" <% if uci:get("openmptcprouter",servername,"disabled") == "1" then %>checked <% end %>/>
</div>
</div>
<%
end)
%>
<div class="cbi-section-create">
<div>
<input type="text" class="cbi-section-create-name" id="cbi.cts.omr-bypass.server." name="add_server_name" data-type="uciname" data-optional="true" />
</div>
<input class="cbi-button cbi-button-add" type="submit" onclick="this.form.cbi_state='add-section'; return true" name="add_server" value="<%:Add a new server%>" />
</div>
</div>
</fieldset>
<fieldset class="cbi-section" id="server_common">
<legend><%:Advanced settings%></legend>
<div class="cbi-value">
<label class="cbi-value-title"><%:Show advanced settings%></label>
<div class="cbi-value-field">
<input type="checkbox" class="cbi-input-checkbox" id="showadv" value="1" onclick="jsshowadv()" />
</div>
</div>
</fieldset>
<span id="advancedsettings" style="display:none;">
<fieldset class="cbi-section" id="serverretrieve">
<legend><%:Retrieve settings from server%></legend>
<div class="cbi-value">
<label class="cbi-value-title"><%:Force retrieve settings%></label>
<div class="cbi-value-field">
<input class="cbi-input-checkbox" type="checkbox" name="forceretrieve" value="1" />
<br />
<div class="cbi-value-description">
<%:Force retrieve all keys from server.%>
</div>
</div>
</div>
</fieldset>
<fieldset class="cbi-section" id="ipv6">
<legend><%:IPv6 settings%></legend>
<div class="cbi-value">
<label class="cbi-value-title"><%:Enable IPv6%></label>
<div class="cbi-value-field">
<select class="cbi-input-select" name="enableipv6" id="enableipv6" data-update="change" size="1">
<option value="1" <% if uci:get("openmptcprouter","settings","disable_ipv6") ~= "0" then %>selected="selected"<% end %>><%:Disabled%></option>
<option value="0" <% if uci:get("openmptcprouter","settings","disable_ipv6") == "0" then %>selected="selected"<% end %>><%:Enabled%></option>
</select>
<br />
<div class="cbi-value-description">
<%:You should disable IPv6 here if server doesn't provide IPv6.%>
</div>
</div>
</div>
<div class="cbi-value">
<label class="cbi-value-title"><%:IPv6 Prefix%></label>
<div class="cbi-value-field">
<input type="text" name="ula" class="cbi-input-text" value="<%=uci:get("network","globals","ula_prefix")%>" />
<br />
<div class="cbi-value-description">
<%:You can use a public IPv6 prefix only if you set only one server.%>
</div>
</div>
</div>
<div class="cbi-value">
<label class="cbi-value-title"><%:Enable DNS64%></label>
<div class="cbi-value-field">
<input class="cbi-input-checkbox" type="checkbox" name="dns64" value="1" <% if uci:get("openmptcprouter","settings","dns64") == "1" then %>checked <% end %>/>
<br />
<div class="cbi-value-description">
<%:If host support NAT64, you can enable DNS64 support.%>
</div>
</div>
</div>
</fieldset>
<fieldset class="cbi-section" id="proxy">
<legend><%:Proxy settings%></legend>
<div class="cbi-section-descr"><%:By default proxy is used for any traffic that is TCP (and UDP for V2Ray/XRay).%></div>
<div class="cbi-value">
<label class="cbi-value-title"><%:Default Proxy%></label>
<div class="cbi-value-field">
<select class="cbi-input-select" name="default_proxy" size="1">
<%
local available_proxys = uci:get("openmptcprouter","vps","available_proxy") or ""
if available_proxys ~= "" then
if (type(available_proxys) ~= "table") then
available_proxys = {available_proxys}
end
for _, proxy in pairs(available_proxys) do
if proxy == "shadowsocks" then %>
<% if nixio.fs.access("/etc/init.d/shadowsocks-libev") then %><option value="shadowsocks" <% if uci:get("openmptcprouter","settings","proxy") == "shadowsocks" then %>selected="selected"<% end %>>Shadowsocks</option><% end %>
<% elseif proxy == "v2ray" then %>
<% if nixio.fs.access("/etc/init.d/v2ray") then %><option value="v2ray" <% if uci:get("openmptcprouter","settings","proxy") == "v2ray" then %>selected="selected"<% end %>>V2Ray VLESS</option><% end %>
<% elseif proxy == "v2ray-vmess" then %>
<% if nixio.fs.access("/etc/init.d/v2ray") then %><option value="v2ray-vmess" <% if uci:get("openmptcprouter","settings","proxy") == "v2ray-vmess" then %>selected="selected"<% end %>>V2Ray VMESS</option><% end %>
<% elseif proxy == "v2ray-trojan" then %>
<% if nixio.fs.access("/etc/init.d/v2ray") then %><option value="v2ray-trojan" <% if uci:get("openmptcprouter","settings","proxy") == "v2ray-trojan" then %>selected="selected"<% end %>>V2Ray TROJAN</option><% end %>
<% elseif proxy == "v2ray-socks" then %>
<% if nixio.fs.access("/etc/init.d/v2ray") then %><option value="v2ray-socks" <% if uci:get("openmptcprouter","settings","proxy") == "v2ray-socks" then %>selected="selected"<% end %>>V2Ray SOCKS</option><% end %>
<% elseif proxy == "xray" then %>
<% if nixio.fs.access("/etc/init.d/xray") then %><option value="xray" <% if uci:get("openmptcprouter","settings","proxy") == "xray" then %>selected="selected"<% end %>>XRay VLESS</option><% end %>
<% elseif proxy == "xray-vless-reality" then %>
<% if nixio.fs.access("/etc/init.d/xray") then %><option value="xray-vless-reality" <% if uci:get("openmptcprouter","settings","proxy") == "xray-vless-reality" then %>selected="selected"<% end %>>XRay VLESS Reality</option><% end %>
<% elseif proxy == "xray-vmess" then %>
<% if nixio.fs.access("/etc/init.d/xray") then %><option value="xray-vmess" <% if uci:get("openmptcprouter","settings","proxy") == "xray-vmess" then %>selected="selected"<% end %>>XRay VMESS</option><% end %>
<% elseif proxy == "xray-trojan" then %>
<% if nixio.fs.access("/etc/init.d/xray") then %><option value="xray-trojan" <% if uci:get("openmptcprouter","settings","proxy") == "xray-trojan" then %>selected="selected"<% end %>>XRay Trojan</option><% end %>
<% elseif proxy == "xray-socks" then %>
<% if nixio.fs.access("/etc/init.d/xray") then %><option value="xray-socks" <% if uci:get("openmptcprouter","settings","proxy") == "xray-socks" then %>selected="selected"<% end %>>XRay Socks</option><% end %>
<% elseif proxy == "xray-shadowsocks" then %>
<% if nixio.fs.access("/etc/init.d/xray") then %><option value="xray-shadowsocks" <% if uci:get("openmptcprouter","settings","proxy") == "xray-shadowsocks" then %>selected="selected"<% end %>>XRay Shadowsocks 2022</option><% end %>
<% elseif proxy == "shadowsocks-rust" or proxy == "shadowsocks-go" then %>
<% if nixio.fs.access("/etc/init.d/shadowsocks-rust") then %><option value="shadowsocks-rust" <% if uci:get("openmptcprouter","settings","proxy") == "shadowsocks-rust" or uci:get("openmptcprouter","settings","proxy") == nil then %>selected="selected"<% end %>>Shadowsocks-Rust 2022</option><% end %>
<% end
end %>
<%
else
%>
<% if nixio.fs.access("/etc/init.d/shadowsocks-libev") then %><option value="shadowsocks" <% if uci:get("openmptcprouter","settings","proxy") == "shadowsocks" then %>selected="selected"<% end %>>Shadowsocks</option><% end %>
<% if nixio.fs.access("/etc/init.d/v2ray") then %><option value="v2ray" <% if uci:get("openmptcprouter","settings","proxy") == "v2ray" then %>selected="selected"<% end %>>V2Ray VLESS</option><% end %>
<% if nixio.fs.access("/etc/init.d/v2ray") then %><option value="v2ray-vmess" <% if uci:get("openmptcprouter","settings","proxy") == "v2ray-vmess" then %>selected="selected"<% end %>>V2Ray VMESS</option><% end %>
<% if nixio.fs.access("/etc/init.d/v2ray") then %><option value="v2ray-trojan" <% if uci:get("openmptcprouter","settings","proxy") == "v2ray-trojan" then %>selected="selected"<% end %>>V2Ray TROJAN</option><% end %>
<% if nixio.fs.access("/etc/init.d/v2ray") then %><option value="v2ray-socks" <% if uci:get("openmptcprouter","settings","proxy") == "v2ray-socks" then %>selected="selected"<% end %>>V2Ray SOCKS</option><% end %>
<% if nixio.fs.access("/etc/init.d/xray") then %><option value="xray" <% if uci:get("openmptcprouter","settings","proxy") == "xray" then %>selected="selected"<% end %>>XRay VLESS</option><% end %>
<% if nixio.fs.access("/etc/init.d/xray") then %><option value="xray-vless-reality" <% if uci:get("openmptcprouter","settings","proxy") == "xray-vless-reality" then %>selected="selected"<% end %>>XRay VLESS Reality</option><% end %>
<% if nixio.fs.access("/etc/init.d/xray") then %><option value="xray-vmess" <% if uci:get("openmptcprouter","settings","proxy") == "xray-vmess" then %>selected="selected"<% end %>>XRay VMESS</option><% end %>
<% if nixio.fs.access("/etc/init.d/xray") then %><option value="xray-trojan" <% if uci:get("openmptcprouter","settings","proxy") == "xray-trojan" then %>selected="selected"<% end %>>XRay Trojan</option><% end %>
<% if nixio.fs.access("/etc/init.d/xray") then %><option value="xray-socks" <% if uci:get("openmptcprouter","settings","proxy") == "xray-socks" then %>selected="selected"<% end %>>XRay Socks</option><% end %>
<% if nixio.fs.access("/etc/init.d/xray") then %><option value="xray-shadowsocks" <% if uci:get("openmptcprouter","settings","proxy") == "xray-shadowsocks" then %>selected="selected"<% end %>>XRay Shadowsocks 2022</option><% end %>
<% if nixio.fs.access("/etc/init.d/shadowsocks-rust") then %><option value="shadowsocks-rust" <% if uci:get("openmptcprouter","settings","proxy") == "shadowsocks-rust" or uci:get("openmptcprouter","settings","proxy") == nil then %>selected="selected"<% end %>>Shadowsocks-Rust 2022</option><% end %>
<%
end
%>
<option value="none" <% if uci:get("openmptcprouter","settings","proxy") == "none" then %>selected="selected"<% end %>>None</option>
</select>
<br />
<div class="cbi-value-description">
<%:Set the default Proxy used for TCP when ShadowSocks is enabled, for TCP and UDP when V2Ray/XRay VLESS, VMESS or Trojan is enabled.%>
<%:Only ShadowSocks is supported with server multiple IPs for now.%>
</div>
</div>
</div>
<% if nixio.fs.access("/etc/init.d/shadowsocks-libev") then %>
<div class="cbi-value">
<label class="cbi-value-title"><%:ShadowSocks key%></label>
<div class="cbi-value-field">
<input type="text" name="shadowsocks_key" placeholder="<%:ShadowSocks key%>" class="cbi-input-text" value="<%=uci:get("shadowsocks-libev","sss0","key")%>" />
<br />
<div class="cbi-value-description">
<%:Key is retrieved from server API by default.%> <%:ShadowSocks is used for TCP.%>
</div>
</div>
</div>
<% end %>
<% if nixio.fs.access("/etc/init.d/xray") or nixio.fs.access("/etc/init.d/shadowsocks-rust") then %>
<div class="cbi-value">
<label class="cbi-value-title"><%:ShadowSocks 2022 key%></label>
<div class="cbi-value-field">
<input type="text" name="shadowsocks2022_key" placeholder="<%:ShadowSocks 2022 key%>" class="cbi-input-text" value="<%=uci:get("shadowsocks-rust","sss0","password")%>" />
<br />
<div class="cbi-value-description">
<%:Key is retrieved from server API by default.%> <%:ShadowSocks is used for TCP.%>
</div>
</div>
</div>
<% end %>
<% if nixio.fs.access("/etc/init.d/v2ray") or nixio.fs.access("/etc/init.d/xray") then %>
<div class="cbi-value">
<label class="cbi-value-title"><%:V2Ray/XRay user id%></label>
<div class="cbi-value-field">
<input type="text" name="v2ray_user" placeholder="<%:V2Ray user%>" class="cbi-input-text" value="<%=uci:get("v2ray","omrout","s_vmess_user_id")%>" />
<br />
<div class="cbi-value-description">
<%:Key is retrieved from server API by default.%> <%:V2Ray is used for TCP and UDP.%>
</div>
</div>
</div>
<% end %>
<div class="cbi-value">
<label class="cbi-value-title"><%:Encryption%></label>
<div class="cbi-value-field">
<select class="cbi-input-select" name="encryption" size="1">
<%
local method=uci:get("openmptcprouter","settings","encryption")
if method == nil and ut.trim(sys.exec("cat /proc/cpuinfo | grep aes")) ~= "" then
method="aes-256-gcm"
elseif method == nil then
method="chacha20"
end
%>
<option value="none" <% if method == "none" then %>selected="selected"<% end %>><%:None%></option>
<option value="aes-256-gcm" <% if method == "aes-256-gcm" then %>selected="selected"<% end %>>AES-256-GCM</option>
<!--<option value="aes-256-cfb" <% if method == "aes-256-cfb" then %>selected="selected"<% end %>>AES-256-CFB</option>-->
<option value="chacha20-ietf-poly1305" <% if method == "chacha20" or method == "chacha20-ietf-poly1305" then %>selected="selected"<% end %>>chacha20</option>
<option value="other" <% if method == "other" or (method ~= "chacha20" and method ~= "aes-256-gcm" and method ~= "aes-256-cfb" and method ~= "chacha20-ietf-poly1305" and method ~= "none") then %>selected="selected"<% end %>><%:other%></option>
</select>
<br />
<div class="cbi-value-description">
<%
if ut.trim(sys.exec("cat /proc/cpuinfo | grep aes")) ~= "" then
%>
<%:An Advanced Encryption Standard (AES) instruction set is integrated in the processor.%>
<% else %>
<%:There is no Advanced Encryption Standard (AES) instruction set integrated in the processor, you should use chacha20.%>
<% end %>
<%:Encryption method is used for Shadowsocks, V2Ray/XRay, Glorytun and OpenVPN.%>
<%:Shadowsocks-go, used on server side when Shadowsocks-Rust is used, doesn't support chacha20, AES-256-GCM is used instead.%>
</div>
</div>
</div>
</fieldset>
<fieldset class="cbi-section" id="vpn">
<legend><%:VPN settings%></legend>
<div class="cbi-section-descr"><%:By default VPN is used for any traffic that is not TCP.%></div>
<% if nixio.fs.access("/usr/sbin/glorytun") or nixio.fs.access("/usr/sbin/glorytun-udp") then %>
<div class="cbi-value">
<label class="cbi-value-title"><%:Glorytun key%></label>
<div class="cbi-value-field">
<input type="text" name="glorytun_key" placeholder="<%:Glorytun key%>" class="cbi-input-text" value="<%=uci:get("glorytun","vpn","key")%>">
<br />
<div class="cbi-value-description">
<%:Key is retrieved from server API by default.%> <%:Glorytun TCP is used by default for UDP and ICMP%>
</div>
</div>
</div>
<% end %>
<% if nixio.fs.access("/usr/sbin/dsvpn") then %>
<div class="cbi-value">
<label class="cbi-value-title"><%:A Dead Simple VPN key%></label>
<div class="cbi-value-field">
<input type="text" name="dsvpn_key" placeholder="<%:A Dead Simple VPN key%>" class="cbi-input-text" value="<%=uci:get("dsvpn","vpn","key")%>">
<br />
<div class="cbi-value-description">
<%:Key is retrieved from server API by default.%> <%:A Dead Simple VPN is a TCP VPN that can replace Glorytun TCP%>
</div>
</div>
</div>
<% end %>
<% if nixio.fs.access("/usr/sbin/mlvpn") then %>
<div class="cbi-value">
<label class="cbi-value-title"><%:MLVPN password%></label>
<div class="cbi-value-field">
<input type="text" name="mlvpn_password" placeholder="<%:MLVPN password%>" class="cbi-input-text" value="<%=uci:get("mlvpn","general","password")%>">
<br />
<div class="cbi-value-description">
<%:Key is retrieved from server API by default.%> <%:MLVPN can replace Glorytun with connections with same latency%>
</div>
</div>
</div>
<% end %>
<% if nixio.fs.access("/usr/sbin/ubond") then %>
<div class="cbi-value">
<label class="cbi-value-title"><%:UBOND password%></label>
<div class="cbi-value-field">
<input type="text" name="ubond_password" placeholder="<%:UBOND password%>" class="cbi-input-text" value="<%=uci:get("ubond","general","password")%>">
<br />
<div class="cbi-value-description">
<%:Key is retrieved from server API by default.%> <%:UBOND can replace Glorytun with connections with same latency%>
</div>
</div>
</div>
<% end %>
<div class="cbi-value">
<label class="cbi-value-title"><%:Default VPN%></label>
<div class="cbi-value-field">
<select class="cbi-input-select" name="default_vpn" size="1">
<%
local available_vpns = uci:get("openmptcprouter","vps","available_vpn") or ""
if available_vpns ~= "" then
if (type(available_vpns) ~= "table") then
available_vpns = {available_vpns}
end
for _, vpn in pairs(available_vpns) do
if vpn == "glorytun_tcp" then
%>
<% if nixio.fs.access("/usr/sbin/glorytun") then %><option value="glorytun_tcp" <% if uci:get("openmptcprouter","settings","vpn") == "glorytun_tcp" then %>selected="selected"<% end %>>Glorytun TCP</option><% end %>
<% elseif vpn == "glorytun_udp" then %>
<% if nixio.fs.access("/usr/sbin/glorytun-udp") then %><option value="glorytun_udp" <% if uci:get("openmptcprouter","settings","vpn") == "glorytun_udp" then %>selected="selected"<% end %>>Glorytun UDP</option><% end %>
<% elseif vpn == "dsvpn" then %>
<% if nixio.fs.access("/usr/sbin/dsvpn") then %><option value="dsvpn" <% if uci:get("openmptcprouter","settings","vpn") == "dsvpn" then %>selected="selected"<% end %>>A Dead Simple VPN</option><% end %>
<% elseif vpn == "mlvpn" then %>
<% if nixio.fs.access("/usr/sbin/mlvpn") then %><option value="mlvpn" <% if uci:get("openmptcprouter","settings","vpn") == "mlvpn" then %>selected="selected"<% end %>>MLVPN</option><% end %>
<% elseif vpn == "ubond" then %>
<% if nixio.fs.access("/usr/sbin/ubond") then %><option value="ubond" <% if uci:get("openmptcprouter","settings","vpn") == "ubond" then %>selected="selected"<% end %>>UBOND</option><% end %>
<% elseif vpn == "openvpn" then %>
<% if nixio.fs.access("/etc/init.d/openvpn") then %><option value="openvpn" <% if uci:get("openmptcprouter","settings","vpn") == "openvpn" then %>selected="selected"<% end %>>OpenVPN TCP</option><% end %>
<% elseif vpn == "openvpn_bonding" then %>
<% if nixio.fs.access("/etc/init.d/openvpnbonding") then %><option value="openvpn_bonding" <% if uci:get("openmptcprouter","settings","vpn") == "openvpn_bonding" then %>selected="selected"<% end %>>OpenVPN Bonding</option><% end %>
<%
end
end
%>
<option value="none" <% if uci:get("openmptcprouter","settings","vpn") == "none" then %>selected="selected"<% end %>>None</option>
<%
else
%>
<% if nixio.fs.access("/usr/sbin/glorytun") then %><option value="glorytun_tcp" <% if uci:get("openmptcprouter","settings","vpn") == "glorytun_tcp" then %>selected="selected"<% end %>>Glorytun TCP</option><% end %>
<% if nixio.fs.access("/usr/sbin/glorytun-udp") then %><option value="glorytun_udp" <% if uci:get("openmptcprouter","settings","vpn") == "glorytun_udp" then %>selected="selected"<% end %>>Glorytun UDP</option><% end %>
<% if nixio.fs.access("/usr/sbin/dsvpn") then %><option value="dsvpn" <% if uci:get("openmptcprouter","settings","vpn") == "dsvpn" then %>selected="selected"<% end %>>A Dead Simple VPN</option><% end %>
<% if nixio.fs.access("/usr/sbin/mlvpn") then %><option value="mlvpn" <% if uci:get("openmptcprouter","settings","vpn") == "mlvpn" then %>selected="selected"<% end %>>MLVPN</option><% end %>
<% if nixio.fs.access("/usr/sbin/ubond") then %><option value="ubond" <% if uci:get("openmptcprouter","settings","vpn") == "ubond" then %>selected="selected"<% end %>>UBOND</option><% end %>
<% if nixio.fs.access("/etc/init.d/openvpn") then %><option value="openvpn" <% if uci:get("openmptcprouter","settings","vpn") == "openvpn" then %>selected="selected"<% end %>>OpenVPN TCP</option><% end %>
<!-- <% if nixio.fs.access("/etc/init.d/openvpnbonding") then %><option value="openvpn_bonding" <% if uci:get("openmptcprouter","settings","vpn") == "openvpn_bonding" then %>selected="selected"<% end %>>OpenVPN Bonding</option><% end %> -->
<option value="none" <% if uci:get("openmptcprouter","settings","vpn") == "none" then %>selected="selected"<% end %>>None</option>
<%
end
%>
</select>
<br />
<div class="cbi-value-description">
<%:Set the default VPN used for ICMP (and UDP if proxy used is shadowsocks), for all traffic if proxy is disabled.%> <%:All VPN available here can do aggregation over MPTCP or using own internal method.%> <%:OpenVPN can't be used in multi VPS configuration.%>
</div>
</div>
</div>
</fieldset>
<fieldset class="cbi-section" id="mptcpovervpn">
<legend><%:MPTCP over VPN settings%></legend>
<div class="cbi-section-descr"><%:MPTCP over VPN should be used only when Multipath TCP is blocked on a connection.%> <%:Only work with Shadowsocks as proxy.%></div>
<div class="cbi-value">
<label class="cbi-value-title"><%:MPTCP over VPN%></label>
<div class="cbi-value-field">
<select class="cbi-input-select" name="mptcpovervpn_vpn" size="1">
<% if nixio.fs.access("/etc/init.d/openvpn") then %><option value="openvpn" <% if uci:get("openmptcprouter","settings","mptcpovervpn") == "openvpn" then %>selected="selected"<% end %>>OpenVPN</option><% end %>
<% if nixio.fs.access("/usr/bin/wg") then %><option value="wireguard" <% if uci:get("openmptcprouter","settings","mptcpovervpn") == "wireguard" or uci:get("openmptcprouter","settings","mptcpovervpn") == nil then %>selected="selected"<% end %>>WireGuard</option><% end %>
</select>
<br />
<div class="cbi-value-description">
<%:Set VPN to use for MPTCP over VPN.%>
</div>
</div>
</div>
</fieldset>
<fieldset class="cbi-section" id="country">
<legend><%:Country settings%></legend>
<div class="cbi-section-descr"><%:Set configuration for countries with some specificities.%></div>
<div class="cbi-value">
<label class="cbi-value-title"><%:Country%></label>
<div class="cbi-value-field">
<select class="cbi-input-select" name="country" size="1">
<option value="" <% if uci:get("openmptcprouter","settings","country") == nil then %>selected="selected"<% end %>><%:None%></option>
<option value="world" <% if uci:get("openmptcprouter","settings","country") == "world" then %>selected="selected"<% end %>><%:World%></option>
<option value="china" <% if uci:get("openmptcprouter","settings","country") == "china" then %>selected="selected"<% end %>><%:China%></option>
</select>
<br />
<div class="cbi-value-description">
<%:For China, set an accessible DNS and disable DNSSEC.%>
</div>
</div>
</div>
</fieldset>
</span>
<hr />
<fieldset class="cbi-section" id="laninterfaces">
<legend><%:LAN interfaces settings%></legend>
<%
for _, iface in ipairs(net:get_networks()) do
local ifname = iface:name()
local firewall_lan = luci.util.trim(luci.sys.exec("uci -q get firewall.zone_lan.network | tr ' ' '\n' | grep \'^" .. ifname .. "$\'"))
if firewall_lan ~= "" then
%>
<h3><%=ifname%></h3>
<fieldset class="cbi-section-node" id="cbi-openmptcprouter-<%=ifname%>">
<input type="hidden" name="intf.<%=ifname%>" value="<%=ifname%>" />
<div class="cbi-value" id="cbi-network-<%=ifname%>-label" data-index="1">
<label class="cbi-value-title"><%:Label%></label>
<div class="cbi-value-field">
<input type="hidden" id="cbid.network.<%=ifname%>.lan" name="cbid.network.<%=ifname%>.lan" value="1">
<input type="hidden" id="cbid.network.<%=ifname%>.gateway" name="cbid.network.<%=ifname%>.gateway" value="<%=uci:get("network",ifname,"gateway")%>">
<input type="text" id="cbid.network.<%=ifname%>.label" name="cbid.network.<%=ifname%>.label" class="cbi-input-text" value="<%=uci:get("network",ifname,"label")%>">
<br />
<div class="cbi-value-description">
<%:Label for the interface%>
</div>
</div>
</div>
<div class="cbi-value" id="cbi-network-<%=ifname%>-proto" data-index="3">
<label class="cbi-value-title"><%:Protocol%></label>
<div class="cbi-value-field">
<% findproto = 0 %>
<select class="cbi-input-select" data-update="change" id="cbid.network.<%=ifname%>.proto" name="cbid.network.<%=ifname%>.proto" size="1">
<option id="cbid.network.<%=ifname%>.proto-static" value="static"<% if uci:get("network",ifname,"proto") == "static" or uci:get("network",ifname,"proto") == "" then findproto = 1 %> selected="selected"<% end %>><%:Static address%></option>
<option id="cbid.network.<%=ifname%>.proto-dhcp" value="dhcp"<% if uci:get("network",ifname,"proto") == "dhcp" then findproto = 1 %> selected="selected"<% end %>><%:DHCP%></option>
<option id="cbid.network.<%=ifname%>.proto-other" value="other"<% if uci:get("network",ifname,"proto") ~= nil and findproto ~= 1 then %> selected="selected"<% end %>><%:Other%></option>
</select>
<br />
<div class="cbi-value-description">
<%:You can use DHCP if you have multiple real ethernet ports.%>
</div>
</div>
</div>
<%
if uci:get("network",ifname,"type") ~= "bridge" then
%>
<div class="cbi-value" id="cbi-network-<%=ifname%>-intf" data-depends="[{"cbid.network.<%=ifname%>.proto":"static"},{"cbid.network.<%=ifname%>.proto":"dhcp"}]" data-index="4">
<label class="cbi-value-title"><%:Physical interface%></label>
<div class="cbi-value-field">
<select class="cbi-input-select" data-update="change" id="cbid.network.<%=ifname%>.intf" name="cbid.network.<%=ifname%>.intf" size="1">
<%
iffind=0
for _, ifacea in ipairs(ifaces) do
if not (ifacea == "lo" or ifacea == "6in4-omr6in4" or ifacea == "mlvpn0" or ifacea:match("^ifb.*") or ifacea:match("^sit.*") or ifacea:match("^gre.*") or ifacea:match("^ip6.*") or ifacea:match("^teql.*") or ifacea:match("^erspan.*") or ifacea:match("^tun.*") or ifacea:match("^bond.*")) and device_notvirtual(ifacea) then
if uci:get("network",ifname,"proto") ~= "macvlan" then
%>
<option value="<%=ifacea%>"<% if uci:get("network",ifname,"device") == ifacea then iffind = 1 %> selected="selected"<% end %>><%=ifacea%></option>
<%
else
%>
<option value="<%=ifacea%>"<% if uci:get("network",ifname,"masterintf") == ifacea then iffind = 1 %> selected="selected"<% end %>><%=ifacea%></option>
<%
end
end
end
if uci:get("network",ifname,"proto") ~= "macvlan" then
if iffind == 0 and uci:get("network",ifname,"device") ~= nil then
%>
<option value="<%=uci:get("network",ifname,"device")%>" selected="selected"><%=uci:get("network",ifname,"device")%></option>
<%
end
else
if iffind == 0 and uci:get("network",ifname,"masterintf") ~= nil then
%>
<option value="<%=uci:get("network",ifname,"masterintf")%>" selected="selected"><%=uci:get("network",ifname,"masterintf")%></option>
<%
end
end
%>
</select>
<br />
<div class="cbi-value-description">
<%:Choose physical interface.%>
</div>
</div>
</div>
<%
end
%>
<div class="cbi-value" id="cbi-network-<%=ifname%>-address" data-depends="[{"cbid.network.<%=ifname%>.proto":"static"},{"cbid.network.<%=ifname%>.proto":"other"},{"cbid.network.<%=ifname%>.type":"macvlan"}]" data-index="5">
<label class="cbi-value-title"><%:IPv4 address%></label>
<div class="cbi-value-field">
<input type="text" id="cbid.network.<%=ifname%>.ipaddr" name="cbid.network.<%=ifname%>.ipaddr" class="cbi-input-text" value="<%=uci:get("network",ifname,"ipaddr")%>" data-type="ip4addr">
</div>
</div>
<div class="cbi-value" id="cbi-network-<%=ifname%>-netmask" data-depends="[{"cbid.network.<%=ifname%>.proto":"static"},{"cbid.network.<%=ifname%>.proto":"other"},{"cbid.network.<%=ifname%>.type":"macvlan"}]" data-index="6">
<label class="cbi-value-title"><%:IPv4 netmask%></label>
<div class="cbi-value-field">
<input type="text" id="cbid.network.<%=ifname%>.netmask" name="cbid.network.<%=ifname%>.netmask" class="cbi-input-text" value="<%=uci:get("network",ifname,"netmask") or "255.255.255.0"%>" data-type="ip4addr">
</div>
</div>
</fieldset>
<%
end
end
%>
<hr />
<fieldset class="cbi-section" id="interfaces">
<legend><%:Interfaces settings%></legend>
<!-- <div class="cbi-section-descr"><%:You must disable DHCP on your modems and set IP in different networks.%></div> -->
<%
for _, iface in ipairs(net:get_networks()) do
local ifname = iface:name()
local firewall_wan = luci.util.trim(luci.sys.exec("uci -q get firewall.zone_wan.network | tr ' ' '\n' | grep \'^" .. ifname .. "$\'"))
local ttl = uci:get("network",ifname .. "_dev","ttl")
if firewall_wan ~= "" then
-- local multipath = uci:get("network",ifname,"multipath")
-- local multipathvpn = uci:get("openmptcprouter",ifname,"multipathvpn")
-- local vpn = uci:get("openmptcprouter",ifname,"vpn")
-- if (multipath ~= nil and multipath ~= "off" and vpn ~= "1") or multipathvpn == "1" then
%>
<div class="cbi-section-remove right">
<input type="submit" name="delete.<%=ifname%>" value="<%:Delete%>" class="cbi-button" />
</div>
<h3><%=ifname%></h3>
<fieldset class="cbi-section-node" id="cbi-openmptcprouter-<%=ifname%>">
<input type="hidden" name="intf.<%=ifname%>" value="<%=ifname%>" />
<div class="cbi-value" id="cbi-network-<%=ifname%>-label" data-index="1">
<label class="cbi-value-title"><%:Label%></label>
<div class="cbi-value-field">
<input type="text" id="cbid.network.<%=ifname%>.label" name="cbid.network.<%=ifname%>.label" class="cbi-input-text" value="<%=uci:get("network",ifname,"label")%>">
<br />
<div class="cbi-value-description">
<%:Label for the interface%>
</div>
</div>
</div>
<div class="cbi-value" id="cbi-network-<%=ifname%>-type" data-index="2">
<label class="cbi-value-title"><%:Type%></label>
<div class="cbi-value-field">
<select class="cbi-input-select" data-update="change" id="cbid.network.<%=ifname%>.type" name="cbid.network.<%=ifname%>.type" size="1">
<option id="cbid.network.<%=ifname%>.type-normal" value="normal"<% if uci:get("network",ifname,"type") ~= "macvlan" and uci:get("network",ifname,"type") ~= "bridge" then %> selected="selected"<% end %>><%:Normal%></option>
<option id="cbid.network.<%=ifname%>.type-macvlan" value="macvlan"<% if uci:get("network",ifname,"type") == "macvlan" then %> selected="selected"<% end %>><%:MacVLAN%></option>
<option id="cbid.network.<%=ifname%>.type-bridge" value="bridge"<% if uci:get("network",ifname,"type") == "bridge" then %> selected="selected"<% end %>><%:Bridge%></option>
</select>
<br />
<div class="cbi-value-description">
<%:Choose MacVLAN if you want to create a virtual interface based on a physical interface.%>
</div>
</div>
</div>
<div class="cbi-value" id="cbi-network-<%=ifname%>-masterintf" data-depends="[{"cbid.network.<%=ifname%>.type":"macvlan"}]" data-index="3">
<label class="cbi-value-title"><%:Physical interface%></label>
<div class="cbi-value-field">
<select class="cbi-input-select" data-update="change" id="cbid.network.<%=ifname%>.masterintf" name="cbid.network.<%=ifname%>.masterintf" size="1">
<%
for _, ifacea in ipairs(ifaces) do
if not (ifacea == "lo" or ifacea == "6in4-omr6in4" or ifacea:match("^ifb.*") or ifacea:match("^sit.*") or ifacea:match("^gre.*") or ifacea:match("^ip6.*") or ifacea:match("^teql.*") or ifacea:match("^erspan.*") or ifacea:match("^tun.*") or ifacea:match("^bond.*")) and device_notvirtual(ifacea) then
%>
<option value="<%=ifacea%>"<% if uci:get("network",ifname,"masterintf") == ifacea then %> selected="selected"<% end %>><%=ifacea%></option>
<%
end
end
%>
</select>
<br />
<div class="cbi-value-description">
<%:Choose physical interface.%>
</div>
</div>
</div>
<div class="cbi-value" id="cbi-network-<%=ifname%>-proto" data-depends="[{"cbid.network.<%=ifname%>.type":"normal"},{"cbid.network.<%=ifname%>.type":"bridge"}]" data-index="3">
<label class="cbi-value-title"><%:Protocol%></label>
<div class="cbi-value-field">
<% findproto = 0 %>
<select class="cbi-input-select" data-update="change" id="cbid.network.<%=ifname%>.proto" name="cbid.network.<%=ifname%>.proto" size="1">
<option id="cbid.network.<%=ifname%>.proto-static" value="static"<% if uci:get("network",ifname,"proto") == "static" or uci:get("network",ifname,"proto") == nil then findproto = 1 %> selected="selected"<% end %>><%:Static address%></option>
<option id="cbid.network.<%=ifname%>.proto-dhcp" value="dhcp"<% if uci:get("network",ifname,"proto") == "dhcp" then findproto = 1 %> selected="selected"<% end %>><%:DHCP%></option>
<option id="cbid.network.<%=ifname%>.proto-dhcpv6" value="dhcpv6"<% if uci:get("network",ifname,"proto") == "dhcpv6" then findproto = 1 %> selected="selected"<% end %>><%:DHCPv6%></option>
<option id="cbid.network.<%=ifname%>.proto-modemmanager" value="modemmanager"<% if uci:get("network",ifname,"proto") == "modemmanager" then findproto = 1 %> selected="selected"<% end %>><%:ModemManager%></option>
<option id="cbid.network.<%=ifname%>.proto-ncm" value="ncm"<% if uci:get("network",ifname,"proto") == "ncm" then findproto = 1 %> selected="selected"<% end %>><%:NCM%></option>
<option id="cbid.network.<%=ifname%>.proto-pppoe" value="pppoe"<% if uci:get("network",ifname,"proto") == "pppoe" then findproto = 1 %> selected="selected"<% end %>><%:PPPoE%></option>
<option id="cbid.network.<%=ifname%>.proto-qmi" value="qmi"<% if uci:get("network",ifname,"proto") == "qmi" then findproto = 1 %> selected="selected"<% end %>><%:QMI%></option>
<option id="cbid.network.<%=ifname%>.proto-other" value="other"<% if uci:get("network",ifname,"proto") ~= nil and findproto ~= 1 then %> selected="selected"<% end %>><%:Other%></option>
</select>
<br />
<div class="cbi-value-description">
<%:You can use DHCP if you have multiple real ethernet ports. Select other if you want to use another protocol available in Network Interfaces page.%>
</div>
</div>
</div>
<div class="cbi-value" id="cbi-network-<%=ifname%>-intf" data-depends="[{"cbid.network.<%=ifname%>.proto":"static"},{"cbid.network.<%=ifname%>.proto":"dhcp"},{"cbid.network.<%=ifname%>.proto":"dhcpv6"}]" data-index="4">
<label class="cbi-value-title"><%:Physical interface%></label>
<div class="cbi-value-field">
<select class="cbi-input-select" data-update="change" id="cbid.network.<%=ifname%>.intf" name="cbid.network.<%=ifname%>.intf" size="1">
<%
iffind=0
uciifname=uci:get("network",ifname,"device")
if uciifname ~= nil then
if uciifname:match("/") then
realifname=uciifname
vlan=""
else
realifname=splitstring(uciifname,'.')[1] or ""
vlan=splitstring(uciifname,'.')[2] or ""
end
end
for _, ifacea in ipairs(ifaces) do
if not (ifacea == "lo" or ifacea == "6in4-omr6in4" or ifacea == "mlvpn0" or ifacea:match("^ifb.*") or ifacea:match("^sit.*") or ifacea:match("^gre.*") or ifacea:match("^ip6.*") or ifacea:match("^teql.*") or ifacea:match("^erspan.*") or ifacea:match("^tun.*") or ifacea:match("^bond.*")) and device_notvirtual(ifacea) then
%>
<option value="<%=ifacea%>"<% if realifname == ifacea then iffind = 1 %> selected="selected"<% end %>><%=ifacea%></option>
<%
end
end
if iffind == 0 and uciifname ~= nil then
%>
<option value="<%=uciifname%>" selected="selected"><%=uciifname%></option>
<%
end
%>
</select>
<label><%:VLAN%></label>
<input type="text" id="cbid.network.<%=ifname%>.vlan" name="cbid.network.<%=ifname%>.vlan" class="cbi-input-text" placeholder="<%:VLAN%>" value="<%=vlan%>" data-optional="true">
<br />
<div class="cbi-value-description">
<%:Choose physical interface.%>
</div>
</div>
</div>
<div class="cbi-value" id="cbi-network-<%=ifname%>-address" data-depends="[{"cbid.network.<%=ifname%>.proto":"static"},{"cbid.network.<%=ifname%>.type":"macvlan"}]" data-index="5">
<label class="cbi-value-title"><%:IPv4 address%></label>
<div class="cbi-value-field">
<input type="text" id="cbid.network.<%=ifname%>.ipaddr" name="cbid.network.<%=ifname%>.ipaddr" class="cbi-input-text" value="<%=uci:get("network",ifname,"ipaddr")%>" data-type="ip4addr">
<br />
<div class="cbi-value-description">
<%:Set an IP in the same network as the modem%>
</div>
</div>
</div>
<div class="cbi-value" id="cbi-network-<%=ifname%>-netmask" data-depends="[{"cbid.network.<%=ifname%>.proto":"static"},{"cbid.network.<%=ifname%>.type":"macvlan"}]" data-index="6">
<label class="cbi-value-title"><%:IPv4 netmask%></label>
<div class="cbi-value-field">
<input type="text" id="cbid.network.<%=ifname%>.netmask" name="cbid.network.<%=ifname%>.netmask" class="cbi-input-text" value="<%=uci:get("network",ifname,"netmask") or "255.255.255.0"%>" data-type="ip4addr">
</div>
</div>
<div class="cbi-value" id="cbi-network-<%=ifname%>-gateway" data-depends="[{"cbid.network.<%=ifname%>.proto":"static"},{"cbid.network.<%=ifname%>.type":"macvlan"}]" data-index="7">
<label class="cbi-value-title"><%:IPv4 gateway%></label>
<div class="cbi-value-field">
<input type="text" id="cbid.network.<%=ifname%>.gateway" name="cbid.network.<%=ifname%>.gateway" class="cbi-input-text" value="<%=uci:get("network",ifname,"gateway")%>" data-type="ip4addr">
<br />
<div class="cbi-value-description">
<%:Set here IP of the modem%>
</div>
</div>
</div>
<%
ipv6list = uci:get_list("network",ifname,"ip6addr")
for key, value in pairs(ipv6list) do
%>
<div class="cbi-value" id="cbi-network-<%=ifname%>-ipv6address" data-index="8">
<label class="cbi-value-title"><%:IPv6 address%></label>
<div class="cbi-value-field">
<input type="text" id="cbid.network.<%=ifname%>.ip6addr" name="cbid.network.<%=ifname%>.ip6addr" class="cbi-input-text" value="<%=value%>" data-type="ip6addr" data-optional="true">
<br />
<div class="cbi-value-description">
<%:Set an IP in the same network as the modem%>
</div>
</div>
</div>
<%
end
if table.getn(ipv6list) ~= 0 then
%>
<div class="cbi-value" id="cbi-network-<%=ifname%>-ip6gw" data-index="9">
<label class="cbi-value-title"><%:IPv6 gateway%></label>
<div class="cbi-value-field">
<input type="text" id="cbid.network.<%=ifname%>.ip6gw" name="cbid.network.<%=ifname%>.ip6gw" class="cbi-input-text" value="<%=uci:get("network",ifname,"ip6gw")%>" data-type="ip6addr" data-optional="true">
<br />
<div class="cbi-value-description">
<%:Set here IP of the modem%>
</div>
</div>
</div>
<%
else
%>
<div class="cbi-value" id="cbi-network-<%=ifname%>-ipv6address" data-depends="[{"enableipv6":"0","cbid.network.<%=ifname%>.proto":"static"},{"enableipv6":"0","cbid.network.<%=ifname%>.type":"macvlan"}]" data-index="8">
<label class="cbi-value-title"><%:IPv6 address%></label>
<div class="cbi-value-field">
<input type="text" id="cbid.network.<%=ifname%>.ip6addr" name="cbid.network.<%=ifname%>.ip6addr" class="cbi-input-text" value="" data-type="ip6addr">
<br />
<div class="cbi-value-description">
<%:Set an IP in the same network as the modem%>
</div>
</div>
</div>
<div class="cbi-value" id="cbi-network-<%=ifname%>-ip6gw" data-depends="[{"enableipv6":"0","cbid.network.<%=ifname%>.proto":"static"},{"enableipv6":"0","cbid.network.<%=ifname%>.type":"macvlan"}]" data-index="9">
<label class="cbi-value-title"><%:IPv6 gateway%></label>
<div class="cbi-value-field">
<input type="text" id="cbid.network.<%=ifname%>.ip6gw" name="cbid.network.<%=ifname%>.ip6gw" class="cbi-input-text" value="<%=uci:get("network",ifname,"ip6gw")%>" data-type="ip6addr">
<br />
<div class="cbi-value-description">
<%:Set here IP of the modem%>
</div>
</div>
</div>
<%
end
%>
<!--
<div class="cbi-value" id="cbi-network-<%=ifname%>-ip6" data-depends="[{"enableipv6":"0","cbid.network.<%=ifname%>.proto":"static"}]" data-index="10">
<label class="cbi-value-title"><%:Accept IPv6 RA%></label>
<div class="cbi-value-field">
<input type="checkbox" id="cbid.network.<%=ifname%>.ipv6" name="cbid.network.<%=ifname%>.ipv6" value="1" <% if uci:get("network",ifname,"ipv6") == "1" then %>checked<% end %> />
</div>
</div>
-->
<div class="cbi-value" id="cbi-network-<%=ifname%>-device-ncm" data-depends="[{"cbid.network.<%=ifname%>.proto":"ncm"}]" data-index="5">
<label class="cbi-value-title"><%:Device%></label>
<div class="cbi-value-field">
<select class="cbi-input-select" data-update="change" id="cbid.network.<%=ifname%>.device.ncm" name="cbid.network.<%=ifname%>.device.ncm" size="1">
<%
iffind=0
for tty in ifttyu do
%>
<option value="<%=tty%>"<% if uci:get("network",ifname,"device") == tty then iffind = 1 %> selected="selected"<% end %>><%=tty%></option>
<%
end
for tty in ifttyc do
%>
<option value="<%=tty%>"<% if uci:get("network",ifname,"device") == tty then iffind = 1 %> selected="selected"<% end %>><%=tty%></option>
<%
end
if iffind == 0 and uci:get("network",ifname,"device") ~= nil then
%>
<option value="<%=uci:get("network",ifname,"device")%>" selected="selected"><%=uci:get("network",ifname,"device")%></option>
<%
end
%>
</select>
</div>
</div>
<div class="cbi-value" id="cbi-network-<%=ifname%>-device-qmi" data-depends="[{"cbid.network.<%=ifname%>.proto":"qmi"}]" data-index="5">
<label class="cbi-value-title"><%:Device%></label>
<div class="cbi-value-field">
<select class="cbi-input-select" data-update="change" id="cbid.network.<%=ifname%>.device.qmi" name="cbid.network.<%=ifname%>.device.qmi" size="1">
<%
iffind=0
for tty in ifttyc do
%>
<option value="<%=tty%>"<% if uci:get("network",ifname,"device") == tty then iffind = 1 %> selected="selected"<% end %>><%=tty%></option>
<%
end
if iffind == 0 and uci:get("network",ifname,"device") ~= nil then
%>
<option value="<%=uci:get("network",ifname,"device")%>" selected="selected"><%=uci:get("network",ifname,"device")%></option>
<%
end
%>
</select>
</div>
</div>
<div class="cbi-value" id="cbi-network-<%=ifname%>-device-modemmanager" data-depends="[{"cbid.network.<%=ifname%>.proto":"modemmanager"}]" data-index="5">
<label class="cbi-value-title"><%:Device%></label>
<div class="cbi-value-field">
<select class="cbi-input-select" data-update="change" id="cbid.network.<%=ifname%>.device.modemmanager" name="cbid.network.<%=ifname%>.device.modemmanager" size="1">
<%
iffind=0
for _, tty in ipairs(alltty) do
%>
<option value="<%=tty%>"<% if uci:get("network",ifname,"device") == tty then iffind = 1 %> selected="selected"<% end %>><%=tty%></option>
<%
end
if iffind == 0 and uci:get("network",ifname,"device") ~= nil then
%>
<option value="<%=uci:get("network",ifname,"device")%>" selected="selected"><%=uci:get("network",ifname,"device")%></option>
<%
end
%>
</select>
</div>
</div>
<div class="cbi-value" id="cbi-network-<%=ifname%>-apn" data-depends="[{"cbid.network.<%=ifname%>.proto":"ncm"},{"cbid.network.<%=ifname%>.proto":"qmi"},{"cbid.network.<%=ifname%>.proto":"modemmanager"}]" data-index="6">
<label class="cbi-value-title"><%:APN%></label>
<div class="cbi-value-field">
<input type="text" id="cbid.network.<%=ifname%>.apn" name="cbid.network.<%=ifname%>.apn" class="cbi-input-text" value="<%=uci:get("network",ifname,"apn")%>">
</div>
</div>
<div class="cbi-value" id="cbi-network-<%=ifname%>-pincode" data-depends="[{"cbid.network.<%=ifname%>.proto":"ncm"},{"cbid.network.<%=ifname%>.proto":"qmi"},{"cbid.network.<%=ifname%>.proto":"modemmanager"}]" data-index="7">
<label class="cbi-value-title"><%:PIN code%></label>
<div class="cbi-value-field">
<input type="text" id="cbid.network.<%=ifname%>.pincode" name="cbid.network.<%=ifname%>.pincode" class="cbi-input-text" value="<%=uci:get("network",ifname,"pincode")%>">
</div>
</div>
<div class="cbi-value" id="cbi-network-<%=ifname%>-mode" data-depends="[{"cbid.network.<%=ifname%>.proto":"ncm"}]" data-index="8">
<label class="cbi-value-title"><%:Service Type%></label>
<div class="cbi-value-field">
<select class="cbi-input-select" data-update="change" id="cbid.network.<%=ifname%>.mode" name="cbid.network.<%=ifname%>.mode" size="1">
<option value=""<% if uci:get("network",ifname,"mode") == "" then %> selected="selected"<% end %>><%:Modem default%></option>
<option value="preferlte"<% if uci:get("network",ifname,"auth") == "preferlte" then %> selected="selected"<% end %>><%:Prefer LTE%></option>
<option value="preferumts"<% if uci:get("network",ifname,"auth") == "preferumts" then %> selected="selected"<% end %>><%:Prefer UMTS%></option>
<option value="lte"<% if uci:get("network",ifname,"auth") == "lte" then %> selected="selected"<% end %>><%:LTE%></option>
<option value="umts"<% if uci:get("network",ifname,"auth") == "umts" then %> selected="selected"<% end %>><%:UMTS/GPRS%></option>
<option value="gsm"<% if uci:get("network",ifname,"auth") == "gsm" then %> selected="selected"<% end %>><%:GPRS only%></option>
<option value="auto"<% if uci:get("network",ifname,"auth") == "auto" then %> selected="selected"<% end %>><%:auto%></option>
</select>
</div>
</div>
<div class="cbi-value" id="cbi-network-<%=ifname%>-auth" data-depends="[{"cbid.network.<%=ifname%>.proto":"qmi"},{"cbid.network.<%=ifname%>.proto":"pppoe"}]" data-index="9">
<label class="cbi-value-title"><%:Authentication Type%></label>
<div class="cbi-value-field">
<select class="cbi-input-select" data-update="change" id="cbid.network.<%=ifname%>.auth" name="cbid.network.<%=ifname%>.auth" size="1">
<option value="none"<% if uci:get("network",ifname,"auth") == "none" then %> selected="selected"<% end %>><%:NONE%></option>
<option value="pap"<% if uci:get("network",ifname,"auth") == "pap" then %> selected="selected"<% end %>><%:PAP%></option>
<option value="chap"<% if uci:get("network",ifname,"auth") == "chap" then %> selected="selected"<% end %>><%:CHAP%></option>
<option value="both"<% if uci:get("network",ifname,"auth") == "both" then %> selected="selected"<% end %>><%:PAP/CHAP%></option>
</select>
</div>
</div>
<div class="cbi-value" id="cbi-network-<%=ifname%>-username" data-depends="[{"cbid.network.<%=ifname%>.proto":"ncm"},{"cbid.network.<%=ifname%>.proto":"qmi"},{"cbid.network.<%=ifname%>.proto":"pppoe"}]" data-index="10">
<label class="cbi-value-title"><%:PAP/CHAP username%></label>
<div class="cbi-value-field">
<input type="text" id="cbid.network.<%=ifname%>.username" name="cbid.network.<%=ifname%>.username" class="cbi-input-text" value="<%=uci:get("network",ifname,"username")%>">
</div>
</div>
<div class="cbi-value" id="cbi-network-<%=ifname%>-password" data-depends="[{"cbid.network.<%=ifname%>.proto":"ncm"},{"cbid.network.<%=ifname%>.proto":"qmi"},{"cbid.network.<%=ifname%>.proto":"pppoe"}]" data-index="11">
<label class="cbi-value-title"><%:PAP/CHAP password%></label>
<div class="cbi-value-field">
<input type="text" id="cbid.network.<%=ifname%>.password" name="cbid.network.<%=ifname%>.password" class="cbi-input-text" value="<%=uci:get("network",ifname,"password")%>">
</div>
</div>
<div class="cbi-value" id="cbi-network-<%=ifname%>-delay" data-depends="[{"cbid.network.<%=ifname%>.proto":"ncm"},{"cbid.network.<%=ifname%>.proto":"qmi"}]" data-index="12">
<label class="cbi-value-title"><%:Modem init timeout%></label>
<div class="cbi-value-field">
<input type="text" id="cbid.network.<%=ifname%>.delay" name="cbid.network.<%=ifname%>.delay" class="cbi-input-text" value="<%=uci:get("network",ifname,"delay")%>">
</div>
</div>
<%
if uci:get("openmptcprouter",ifname,"multipathvpn") == "1" then
%>
<div class="cbi-value" id="cbi-network-<%=ifname%>-multipath" data-index="13">
<label class="cbi-value-title"><%:Multipath TCP%></label>
<div class="cbi-value-field">
<select class="cbi-input-select" data-update="change" id="cbid.network.<%=ifname%>.multipath" name="cbid.network.<%=ifname%>.multipath" size="1">
<option value="on"<% if uci:get("network","ovpn" .. ifname,"multipath") == "on" then %> selected="selected"<% end %>><%:Enabled%></option>
<option value="off"<% if uci:get("network","ovpn" .. ifname,"multipath") == "off" then %> selected="selected"<% end %>><%:Disabled%></option>
<option value="master"<% if uci:get("network","ovpn" .. ifname,"multipath") == "master" then %> selected="selected"<% end %>><%:Master%></option>
<option value="backup"<% if uci:get("network","ovpn" .. ifname,"multipath") == "backup" then %> selected="selected"<% end %>><%:Backup%></option>
</select>
<br />
<div class="cbi-value-description">
<%:Only one interface must be set as "Master", this should be the most stable interface.%>
</div>
</div>
</div>
<% else %>
<div class="cbi-value" id="cbi-network-<%=ifname%>-multipath" data-index="13">
<label class="cbi-value-title"><%:Multipath TCP%></label>
<div class="cbi-value-field">
<select class="cbi-input-select" data-update="change" id="cbid.network.<%=ifname%>.multipath" name="cbid.network.<%=ifname%>.multipath" size="1">
<option value="on"<% if uci:get("network",ifname,"multipath") == "on" then %> selected="selected"<% end %>><%:Enabled%></option>
<option value="off"<% if uci:get("network",ifname,"multipath") == "off" then %> selected="selected"<% end %>><%:Disabled%></option>
<option value="master"<% if uci:get("network",ifname,"multipath") == "master" then %> selected="selected"<% end %>><%:Master%></option>
<option value="backup"<% if uci:get("network",ifname,"multipath") == "backup" then %> selected="selected"<% end %>><%:Backup%></option>
</select>
</div>
</div>
<%
end
%>
<div class="cbi-value" data-index="14">
<label class="cbi-value-title"><%:Force TTL%></label>
<div class="cbi-value-field">
<input type="text" name="cbid.network.<%=ifname%>.ttl" class="cbi-input-text" value="<%=ttl%>" data-type="uinteger" data-optional="true">
<br />
<div class="cbi-value-description">
<%:You can force a TTL. Some LTE provider detect tethering by inpecting packet TTL value, setting it to 65 often solve the issue.%>
</div>
</div>
</div>
<%
local download = "0"
local upload = "0"
download = uci:get("network",ifname,"downloadspeed") or "0"
upload = uci:get("network",ifname,"uploadspeed") or "0"
cake = uci:get("sqm",ifname,"qdisc") or "cake"
--if download == "0" or upload == "0" then
-- if nixio.fs.access("/etc/init.d/sqm") then
-- download = uci:get("sqm",ifname,"download")
-- upload = uci:get("sqm",ifname,"upload")
-- else
-- download = uci:get("qos",ifname,"download")
-- upload = uci:get("qos",ifname,"upload")