|
9 | 9 | botname: { value: "", required: true }, |
10 | 10 | verboselogging: { value: false, required: false }, |
11 | 11 | loginmode: { value: "user", required: true }, |
| 12 | + |
| 13 | + useproxy: { value: false, required: false }, |
| 14 | + usewss: { value: false, required: false }, |
| 15 | + host: { value: "", required: false }, |
| 16 | + sockstype: { value: "5", required: false }, |
| 17 | + port: { value: 6667, required: false, validate:function(v) { return ((v === "") || (RED.validators.number(v) && (v >= 0) && (v <= 2147483))) }}, |
| 18 | + username: { value: "anonymous", required: false }, |
| 19 | + password: { value: "", required: false }, |
| 20 | + secret: { value: "", required: false }, |
| 21 | + mtproxy: { value: false, required: false }, |
| 22 | + timeout: { value: 2, required: false, validate:function(v) { return ((v === "") || (RED.validators.number(v) && (v >= 0) && (v <= 2147483))) }}, |
12 | 23 | }, |
13 | 24 | credentials: { |
14 | 25 | apiid: { value: 0, required: true, validate:function(v) { return ((v === "") || (RED.validators.number(v) && (v >= 0) && (v <= 4294967295))) }}, |
|
22 | 33 | return this.botname; |
23 | 34 | }, |
24 | 35 | oneditprepare: function() { |
25 | | - // polling or webhook |
| 36 | + // polling or webhook |
26 | 37 | var updateLoginMode = function() { |
27 | 38 | var mode = $("#node-config-input-loginmode").val(); |
28 | 39 | if (mode == "user") { |
|
38 | 49 | updateLoginMode(); |
39 | 50 | $("#node-config-input-loginmode").change(updateLoginMode); |
40 | 51 |
|
| 52 | + |
| 53 | + // proxy on / off |
| 54 | + var useproxy = function() { |
| 55 | + var mode = $("#node-config-input-useproxy").prop('checked'); |
| 56 | + if (mode === false) { |
| 57 | + $("#useproxy").hide(); |
| 58 | + } else { |
| 59 | + $("#useproxy").show(); |
| 60 | + } |
| 61 | + }; |
| 62 | + useproxy(); |
| 63 | + $("#node-config-input-useproxy").change(useproxy); |
| 64 | + |
| 65 | + |
41 | 66 | var login = function() { |
42 | | - |
43 | 67 | let apiId = $("#node-config-input-apiid").val(); |
44 | 68 | let apiHash = $("#node-config-input-apihash").val(); |
45 | 69 | let phoneNumber = $("#node-config-input-phonenumber").val(); |
46 | 70 | let password = $("#node-config-input-password").val(); |
47 | 71 | let botToken = $("#node-config-input-bottoken").val(); |
48 | 72 | let loginMode = $("#node-config-input-loginmode").val(); |
| 73 | + let useProxy = $("#node-config-input-useproxy").val(); |
| 74 | + let useWSS = $("#node-config-input-usewss").val(); |
| 75 | + let proxy; |
| 76 | + |
| 77 | + if (useProxy) { |
| 78 | + proxy = { |
| 79 | + ip: $("#node-config-input-host").val(), |
| 80 | + socksType: Number($("#node-config-input-sockstype").val()), |
| 81 | + port: Number($("#node-config-input-port").val()), |
| 82 | + username: $("#node-config-input-username").val(), |
| 83 | + password: $("#node-config-input-password").val(), |
| 84 | + secret: $("#node-config-input-secret").val(), |
| 85 | + MTProxy: $("#node-config-input-mtproxy").val(), |
| 86 | + timeout: Number($("#node-config-input-timeout").val()), |
| 87 | + }; |
| 88 | + } |
49 | 89 |
|
50 | 90 | if (apiId !== '' && apiHash) { |
51 | 91 | let parameters = { |
|
54 | 94 | phoneNumber : phoneNumber, |
55 | 95 | password : password, |
56 | 96 | botToken : botToken, |
57 | | - loginMode : loginMode |
| 97 | + loginMode : loginMode, |
| 98 | + proxy : proxy, |
| 99 | + useWSS : useWSS, |
58 | 100 | } |
59 | 101 |
|
60 | 102 | $("#loginbuttontip").text("Login started: enter code in field below."); |
|
199 | 241 |
|
200 | 242 | <hr align="middle"/> |
201 | 243 |
|
| 244 | + <div class="form-row"> |
| 245 | + <label for="node-config-input-useproxy"><i class="fa fa-lock"></i> Use Proxy</label> |
| 246 | + <input type="checkbox" id="node-config-input-useproxy" style="display: inline-block; width: auto; vertical-align: top;"> |
| 247 | + </div> |
| 248 | + <div class="form-row hidden" id="useproxy" style="background: var(--red-ui-tertiary-background)"> |
| 249 | + <label style="width: auto"><i class="fa fa-cogs"></i> Proxy Options:</label> |
| 250 | + |
| 251 | + <div class="form-row" style="background: #fff; margin-left: 20px"> |
| 252 | + <div class="form-row"> |
| 253 | + <label for="node-config-input-mtproxy"><i class="fa fa-telegram"></i> MT-Proxy</label> |
| 254 | + <input type="checkbox" id="node-config-input-mtproxy" style="display: inline-block; width: auto; vertical-align: top;"> |
| 255 | + </div> |
| 256 | + <div class="form-row"> |
| 257 | + <label for="node-config-input-sockstype"><i class="fa fa-user-secret"></i> Socks Type</label> |
| 258 | + <select id="node-config-input-sockstype"> |
| 259 | + <option value="4">socks4</option> |
| 260 | + <option value="5">socks5</option> |
| 261 | + </select> |
| 262 | + </div> |
| 263 | + <div class="form-row"> |
| 264 | + <label for="node-config-input-host"><i class="fa fa-desktop"></i> Host</label> |
| 265 | + <input type="text" id="node-config-input-host" placeholder="(IP or hostname of the proxy.)"> |
| 266 | + </div> |
| 267 | + <div class="form-row"> |
| 268 | + <label for="node-config-input-port"><i class="fa fa-random"></i> Port</label> |
| 269 | + <input type="text" id="node-config-input-port" placeholder="(Port of the proxy.)"> |
| 270 | + </div> |
| 271 | + <div class="form-row"> |
| 272 | + <label for="node-config-input-username"><i class="fa fa-user"></i> Username</label> |
| 273 | + <input type="text" id="node-config-input-username" placeholder="(Username of the socks proxy.)"> |
| 274 | + </div> |
| 275 | + <div class="form-row"> |
| 276 | + <label for="node-config-input-password"><i class="fa fa-key"></i> Password</label> |
| 277 | + <input type="text" id="node-config-input-password" placeholder="(Password of the socks proxy.)"> |
| 278 | + </div> |
| 279 | + <div class="form-row"> |
| 280 | + <label for="node-config-input-secret"><i class="fa fa-user-secret"></i> Secret</label> |
| 281 | + <input type="text" id="node-config-input-secret" placeholder="(Secret of the mtproxy.)"> |
| 282 | + </div> |
| 283 | + <div class="form-row"> |
| 284 | + <label for="node-config-input-timeout"><i class="fa fa-clock-o"></i> Timeout s</label> |
| 285 | + <input type="text" id="node-config-input-timeout" placeholder="(Connect timeout in seconds e.g.: 2)"> |
| 286 | + </div> |
| 287 | + <div class="form-row"> |
| 288 | + <label for="node-config-input-usewss"><i class="fa fa-lock"></i> Use WSS</label> |
| 289 | + <input type="checkbox" id="node-config-input-usewss" style="display: inline-block; width: auto; vertical-align: top;"> |
| 290 | + </div> |
| 291 | + </div> |
| 292 | + |
| 293 | + <div class="form-tips" style="width: auto"><b>Tip:</b> SOCKS proxy support is optional can can only be used with a valid proxy server, port, username and password.</div> |
| 294 | + </div> |
| 295 | + |
| 296 | + <hr align="middle"/> |
| 297 | + |
202 | 298 | <div class="form-row"> |
203 | 299 | <label for="node-config-input-verboselogging"><i class="fa fa-search"></i> Verbose Logging</label> |
204 | 300 | <input type="checkbox" id="node-config-input-verboselogging" style="display: inline-block; width: auto; vertical-align: top;"> |
|
0 commit comments