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
|
'use strict';
'require form';
'require fs';
'require uci';
'require ui';
'require view';
return view.extend({
load() {
return Promise.all([
uci.load('sshtunnel'),
]);
},
render() {
let m, s, o;
m = new form.Map('sshtunnel', _('SSH Tunnels'),
_('This configures <a %s>SSH Tunnels</a>.')
.format('href="https://openwrt.org/docs/guide-user/services/ssh/sshtunnel"')
);
s = m.section(form.GridSection, 'tunnelR', _('Remote Tunnels'),
_('Forward a port on the remote host to a service on the local host.')
);
s.anonymous = true;
s.addremove = true;
s.nodescriptions = true;
o = s.option(form.Flag, 'enabled', _('Enabled'));
o.default = '1';
o = _addServerOption(s);
o = s.option(form.Value, 'remoteaddress', _('Remote address'),
_('Bind IP address e.g. <code>192.168.1.1</code> or hostname e.g. <code>localhost</code>.') + '<br/>' +
_('<code>*</code> means to listen all interfaces <b>including public</b>.')
);
o.datatype = 'or(host, "*")';
o.default = '*';
o.rmempty = false;
o = s.option(form.Value, 'remoteport', _('Remote port'));
o.placeholder = '80';
o.datatype = 'port';
o.rmempty = false;
o = s.option(form.Value, 'localaddress', _('Local address'),
_('Bind IP address e.g. <code>192.168.1.1</code> or hostname e.g. <code>localhost</code>.')
);
o.datatype = 'host';
o.default = 'localhost';
o.rmempty = false;
o = s.option(form.Value, 'localport', _('Local port'));
o.datatype = 'port';
o.placeholder = '80';
o.rmempty = false;
s = m.section(form.GridSection, 'tunnelL', _('Local Tunnels'),
_('Forward a port on the local host to a service on the remote host.')
);
s.anonymous = true;
s.addremove = true;
s.nodescriptions = true;
o = s.option(form.Flag, 'enabled', _('Enabled'));
o.default = '1';
o = _addServerOption(s);
o = s.option(form.Value, 'localaddress', _('Local address'),
_('Bind IP address e.g. <code>192.168.1.1</code> or hostname e.g. <code>localhost</code>.') + '<br/>' +
_('<code>*</code> means to listen all interfaces <b>including public</b>.')
);
o.datatype = 'or(host, "*")';
o.placeholder = '192.168.1.1'; // not the default * public iface because a user must explicitly configure it
o.rmempty = false;
o = s.option(form.Value, 'localport', _('Local port'));
o.datatype = 'port';
o.placeholder = '80';
o.rmempty = false;
o = s.option(form.Value, 'remoteaddress', _('Remote address'),
_('Bind IP address e.g. <code>192.168.1.1</code> or hostname e.g. <code>localhost</code>.')
);
o.datatype = 'host';
o.default = 'localhost';
o.rmempty = false;
o = s.option(form.Value, 'remoteport', _('Remote port'));
o.datatype = 'port';
o.default = '80';
o.rmempty = false;
s = m.section(form.GridSection, 'tunnelD', _('Dynamic Tunnels'),
_('SOCKS proxy via remote host.')
);
s.anonymous = true;
s.addremove = true;
s.nodescriptions = true;
o = s.option(form.Flag, 'enabled', _('Enabled'));
o.default = '1';
o = _addServerOption(s);
o = s.option(form.Value, 'localaddress', _('Local address'),
_('Bind IP address e.g. <code>192.168.1.1</code> or hostname e.g. <code>localhost</code>.') + '<br/>' +
_('<code>*</code> means to listen all interfaces <b>including public</b>.')
);
o.datatype = 'or(host, "*")';
o.placeholder = '192.168.1.1'; // not the default * public iface because a user must explicitly configure it
o.rmempty = false;
o = s.option(form.Value, 'localport', _('Local port'));
o.datatype = 'port';
o.default = '1080';
o.rmempty = false;
s = m.section(form.GridSection, 'tunnelW', _('VPN Tunnels'),
_('Configure TUN/TAP devices for VPN tunnels.')
);
s.anonymous = true;
s.addremove = true;
s.nodescriptions = true;
o = s.option(form.Flag, 'enabled', _('Enabled'));
o.default = '1';
o = _addServerOption(s);
o = s.option(form.ListValue, 'vpntype', _('VPN type'));
o.value('point-to-point', 'TUN (point-to-point)');
o.value('ethernet', 'TAP (ethernet)');
o.default = 'point-to-point';
o = s.option(form.Value, 'localdev', _('Local dev'));
o.default = 'any';
o.datatype = 'or("any", min(0))';
o.rmempty = false;
o = s.option(form.Value, 'remotedev', _('Remote dev'));
o.default = 'any';
o.datatype = 'or("any", min(0))';
o.rmempty = false;
return m.render();
},
});
function _addServerOption(s) {
const o = s.option(form.ListValue, 'server', _('Server'));
o.datatype = 'uciname';
o.rmempty = false;
uci.sections('sshtunnel', 'server', function (s, sectionName) {
o.value(sectionName, s.hostname ? '%s (%s)'.format(sectionName, s.hostname) : sectionName);
});
return o;
}
|