├── LICENSE ├── Makefile ├── README.md ├── dev ├── connections.js ├── luci-app-qosmate.json ├── luci.qosmate └── menu.d │ └── luci-app-qosmate.json ├── dir_fixups.txt ├── file_fixups.txt ├── htdocs └── luci-static │ └── resources │ └── view │ ├── advanced.js │ ├── cake.js │ ├── connections.js │ ├── custom_rules.js │ ├── hfsc.js │ ├── ipsets.js │ ├── rules.js │ ├── settings.js │ └── statistics.js ├── po ├── README.md ├── de.po ├── templates │ └── qosmate.pot └── zh_Hans │ └── qosmate.po └── root └── usr ├── libexec └── rpcd │ ├── luci.qosmate │ └── luci.qosmate_stats └── share ├── luci └── menu.d │ └── luci-app-qosmate.json └── rpcd └── acl.d └── luci-app-qosmate.json /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | include $(TOPDIR)/rules.mk 2 | 3 | PKG_NAME:=luci-app-qosmate 4 | PKG_VERSION:=1.0.14 5 | PKG_RELEASE:=1 6 | 7 | PKG_MAINTAINER:=Markus Hütter 8 | PKG_LICENSE:=GPL-3.0-or-later 9 | 10 | LUCI_TITLE:=LuCI support for QoSmate 11 | LUCI_DEPENDS:=+qosmate +luci-lib-jsonc +lua 12 | LUCI_PKGARCH:=all 13 | 14 | PO_LANG:=de 15 | 16 | include $(TOPDIR)/feeds/luci/luci.mk 17 | 18 | define Build/Compile 19 | endef 20 | 21 | define Package/$(PKG_NAME)/install 22 | $(INSTALL_DIR) $(1)/www/luci-static/resources/view/qosmate 23 | $(INSTALL_DIR) $(1)/usr/share/luci/menu.d 24 | $(INSTALL_DIR) $(1)/usr/share/rpcd/acl.d 25 | $(INSTALL_DIR) $(1)/usr/libexec/rpcd 26 | 27 | $(INSTALL_DATA) ./htdocs/luci-static/resources/view/*.js $(1)/www/luci-static/resources/view/qosmate/ 28 | 29 | $(INSTALL_DATA) ./root/usr/share/luci/menu.d/luci-app-qosmate.json $(1)/usr/share/luci/menu.d/ 30 | $(INSTALL_DATA) ./root/usr/share/rpcd/acl.d/luci-app-qosmate.json $(1)/usr/share/rpcd/acl.d/ 31 | 32 | $(INSTALL_BIN) ./root/usr/libexec/rpcd/luci.qosmate $(1)/usr/libexec/rpcd/ 33 | endef 34 | 35 | # call BuildPackage - OpenWrt buildroot signature 36 | 37 | $(eval $(call BuildPackage,$(PKG_NAME))) 38 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # luci-app-qosmate 2 | 3 | This repository uses the central README from the [qosmate repository](https://github.com/hudra0/qosmate). 4 | 5 | 6 | 7 | 8 | #### Install one-liner: 9 | 10 | ```bash 11 | mkdir -p /www/luci-static/resources/view/qosmate /usr/share/luci/menu.d /usr/share/rpcd/acl.d /usr/libexec/rpcd && \ 12 | wget -O /www/luci-static/resources/view/qosmate/settings.js https://raw.githubusercontent.com/hudra0/luci-app-qosmate/main/htdocs/luci-static/resources/view/settings.js && \ 13 | wget -O /www/luci-static/resources/view/qosmate/hfsc.js https://raw.githubusercontent.com/hudra0/luci-app-qosmate/main/htdocs/luci-static/resources/view/hfsc.js && \ 14 | wget -O /www/luci-static/resources/view/qosmate/cake.js https://raw.githubusercontent.com/hudra0/luci-app-qosmate/main/htdocs/luci-static/resources/view/cake.js && \ 15 | wget -O /www/luci-static/resources/view/qosmate/advanced.js https://raw.githubusercontent.com/hudra0/luci-app-qosmate/main/htdocs/luci-static/resources/view/advanced.js && \ 16 | wget -O /www/luci-static/resources/view/qosmate/rules.js https://raw.githubusercontent.com/hudra0/luci-app-qosmate/main/htdocs/luci-static/resources/view/rules.js && \ 17 | wget -O /www/luci-static/resources/view/qosmate/connections.js https://raw.githubusercontent.com/hudra0/luci-app-qosmate/main/htdocs/luci-static/resources/view/connections.js && \ 18 | wget -O /www/luci-static/resources/view/qosmate/custom_rules.js https://raw.githubusercontent.com/hudra0/luci-app-qosmate/main/htdocs/luci-static/resources/view/custom_rules.js && \ 19 | wget -O /www/luci-static/resources/view/qosmate/ipsets.js https://raw.githubusercontent.com/hudra0/luci-app-qosmate/main/htdocs/luci-static/resources/view/ipsets.js && \ 20 | wget -O /www/luci-static/resources/view/qosmate/statistics.js https://raw.githubusercontent.com/hudra0/luci-app-qosmate/main/htdocs/luci-static/resources/view/statistics.js && \ 21 | wget -O /usr/share/luci/menu.d/luci-app-qosmate.json https://raw.githubusercontent.com/hudra0/luci-app-qosmate/main/root/usr/share/luci/menu.d/luci-app-qosmate.json && \ 22 | wget -O /usr/share/rpcd/acl.d/luci-app-qosmate.json https://raw.githubusercontent.com/hudra0/luci-app-qosmate/main/root/usr/share/rpcd/acl.d/luci-app-qosmate.json && \ 23 | wget -O /usr/libexec/rpcd/luci.qosmate https://raw.githubusercontent.com/hudra0/luci-app-qosmate/main/root/usr/libexec/rpcd/luci.qosmate && \ 24 | wget -O /usr/libexec/rpcd/luci.qosmate_stats https://raw.githubusercontent.com/hudra0/luci-app-qosmate/main/root/usr/libexec/rpcd/luci.qosmate_stats && \ 25 | chmod +x /usr/libexec/rpcd/luci.qosmate && \ 26 | chmod +x /usr/libexec/rpcd/luci.qosmate_stats && \ 27 | /etc/init.d/rpcd restart && \ 28 | /etc/init.d/uhttpd restart 29 | # End of command - Press Enter after pasting 30 | 31 | ``` 32 | -------------------------------------------------------------------------------- /dev/connections.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 'require view'; 3 | 'require poll'; 4 | 'require rpc'; 5 | 'require ui'; 6 | 'require form'; 7 | 8 | var callQoSmateConntrackDSCP = rpc.declare({ 9 | object: 'luci.qosmate', 10 | method: 'getConntrackDSCP', 11 | expect: { } 12 | }); 13 | 14 | var dscpToString = function(mark) { 15 | var dscp = mark & 0x3F; 16 | var dscpMap = { 17 | 0: 'CS0', 18 | 8: 'CS1', 19 | 10: 'AF11', 20 | 12: 'AF12', 21 | 14: 'AF13', 22 | 16: 'CS2', 23 | 18: 'AF21', 24 | 20: 'AF22', 25 | 22: 'AF23', 26 | 24: 'CS3', 27 | 26: 'AF31', 28 | 28: 'AF32', 29 | 30: 'AF33', 30 | 32: 'CS4', 31 | 34: 'AF41', 32 | 36: 'AF42', 33 | 38: 'AF43', 34 | 40: 'CS5', 35 | 46: 'EF', 36 | 48: 'CS6', 37 | 56: 'CS7' 38 | }; 39 | return dscpMap[dscp] || dscp.toString(); 40 | }; 41 | 42 | var formatSize = function(bytes) { 43 | var sizes = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB']; 44 | if (bytes == 0) return '0 B'; 45 | var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024))); 46 | return Math.round(bytes / Math.pow(1024, i) * 100) / 100 + ' ' + sizes[i]; 47 | }; 48 | 49 | var convertToKbps = function(bytesPerSecond) { 50 | return (bytesPerSecond * 8 / 1000).toFixed(2) + ' Kbit/s'; 51 | }; 52 | 53 | return view.extend({ 54 | pollInterval: 1, 55 | lastData: {}, 56 | filter: '', 57 | sortColumn: 'bytes', 58 | sortDescending: true, 59 | connectionHistory: {}, 60 | historyLength: 10, 61 | lastUpdateTime: 0, 62 | 63 | load: function() { 64 | return Promise.all([ 65 | callQoSmateConntrackDSCP() 66 | ]); 67 | }, 68 | 69 | render: function(data) { 70 | var view = this; 71 | var connections = []; 72 | if (data[0] && data[0].connections) { 73 | connections = Object.values(data[0].connections); 74 | } 75 | 76 | var filterInput = E('input', { 77 | 'type': 'text', 78 | 'placeholder': _('Filter by IP, IP:Port, Port, Protocol or DSCP'), 79 | 'style': 'margin-bottom: 10px; width: 300px;', 80 | 'value': view.filter 81 | }); 82 | 83 | filterInput.addEventListener('input', function(ev) { 84 | view.filter = ev.target.value.toLowerCase(); 85 | view.updateTable(connections); 86 | }); 87 | 88 | var table = E('table', { 'class': 'table cbi-section-table', 'id': 'qosmate_connections' }, [ 89 | E('tr', { 'class': 'tr table-titles' }, [ 90 | E('th', { 'class': 'th' }, E('a', { 'href': '#', 'click': this.sortTable.bind(this, 'protocol') }, [ _('Protocol'), this.createSortIndicator('protocol') ])), 91 | E('th', { 'class': 'th' }, E('a', { 'href': '#', 'click': this.sortTable.bind(this, 'src') }, [ _('Source'), this.createSortIndicator('src') ])), 92 | E('th', { 'class': 'th' }, E('a', { 'href': '#', 'click': this.sortTable.bind(this, 'dst') }, [ _('Destination'), this.createSortIndicator('dst') ])), 93 | E('th', { 'class': 'th' }, E('a', { 'href': '#', 'click': this.sortTable.bind(this, 'dscp') }, [ _('DSCP'), this.createSortIndicator('dscp') ])), 94 | E('th', { 'class': 'th' }, E('a', { 'href': '#', 'click': this.sortTable.bind(this, 'bytes') }, [ _('Bytes'), this.createSortIndicator('bytes') ])), 95 | E('th', { 'class': 'th' }, E('a', { 'href': '#', 'click': this.sortTable.bind(this, 'packets') }, [ _('Packets'), this.createSortIndicator('packets') ])), 96 | E('th', { 'class': 'th' }, E('a', { 'href': '#', 'click': this.sortTable.bind(this, 'avgPps') }, [ _('Avg PPS'), this.createSortIndicator('avgPps') ])), 97 | E('th', { 'class': 'th' }, E('a', { 'href': '#', 'click': this.sortTable.bind(this, 'maxPps') }, [ _('Max PPS'), this.createSortIndicator('maxPps') ])), 98 | E('th', { 'class': 'th' }, E('a', { 'href': '#', 'click': this.sortTable.bind(this, 'avgBps') }, [ _('Avg BPS'), this.createSortIndicator('avgBps') ])) 99 | ]) 100 | ]); 101 | 102 | view.updateTable = function(connections) { 103 | // Remove all rows except the header 104 | while (table.rows.length > 1) { 105 | table.deleteRow(1); 106 | } 107 | 108 | var currentTime = Date.now() / 1000; 109 | var timeDiff = currentTime - view.lastUpdateTime; 110 | view.lastUpdateTime = currentTime; 111 | 112 | connections.forEach(function(conn) { 113 | var key = conn.layer3 + conn.protocol + conn.src + conn.sport + conn.dst + conn.dport; 114 | var lastConn = view.lastData[key]; 115 | 116 | if (!view.connectionHistory[key]) { 117 | view.connectionHistory[key] = { 118 | inPpsHistory: [], 119 | outPpsHistory: [], 120 | inBpsHistory: [], 121 | outBpsHistory: [], 122 | lastInPackets: conn.in_packets, 123 | lastOutPackets: conn.out_packets, 124 | lastInBytes: conn.in_bytes, 125 | lastOutBytes: conn.out_bytes, 126 | lastTimestamp: currentTime 127 | }; 128 | } 129 | 130 | var history = view.connectionHistory[key]; 131 | var instantInPps = 0, instantOutPps = 0, instantInBps = 0, instantOutBps = 0; 132 | 133 | if (lastConn && timeDiff > 0) { 134 | var inPacketDiff = Math.max(0, conn.in_packets - history.lastInPackets); 135 | var outPacketDiff = Math.max(0, conn.out_packets - history.lastOutPackets); 136 | var inBytesDiff = Math.max(0, conn.in_bytes - history.lastInBytes); 137 | var outBytesDiff = Math.max(0, conn.out_bytes - history.lastOutBytes); 138 | 139 | instantInPps = Math.round(inPacketDiff / timeDiff); 140 | instantOutPps = Math.round(outPacketDiff / timeDiff); 141 | instantInBps = Math.round(inBytesDiff / timeDiff); 142 | instantOutBps = Math.round(outBytesDiff / timeDiff); 143 | 144 | history.inPpsHistory.push(instantInPps); 145 | history.outPpsHistory.push(instantOutPps); 146 | history.inBpsHistory.push(instantInBps); 147 | history.outBpsHistory.push(instantOutBps); 148 | 149 | if (history.inPpsHistory.length > view.historyLength) { 150 | history.inPpsHistory.shift(); 151 | history.outPpsHistory.shift(); 152 | history.inBpsHistory.shift(); 153 | history.outBpsHistory.shift(); 154 | } 155 | } 156 | 157 | history.lastInPackets = conn.in_packets; 158 | history.lastOutPackets = conn.out_packets; 159 | history.lastInBytes = conn.in_bytes; 160 | history.lastOutBytes = conn.out_bytes; 161 | history.lastTimestamp = currentTime; 162 | 163 | var avgInPps = Math.round(history.inPpsHistory.reduce((a, b) => a + b, 0) / history.inPpsHistory.length) || 0; 164 | var avgOutPps = Math.round(history.outPpsHistory.reduce((a, b) => a + b, 0) / history.outPpsHistory.length) || 0; 165 | var avgInBps = Math.round(history.inBpsHistory.reduce((a, b) => a + b, 0) / history.inBpsHistory.length) || 0; 166 | var avgOutBps = Math.round(history.outBpsHistory.reduce((a, b) => a + b, 0) / history.outBpsHistory.length) || 0; 167 | var maxInPps = Math.max(...history.inPpsHistory, 0); 168 | var maxOutPps = Math.max(...history.outPpsHistory, 0); 169 | 170 | conn.avgInPps = avgInPps; 171 | conn.avgOutPps = avgOutPps; 172 | conn.maxInPps = maxInPps; 173 | conn.maxOutPps = maxOutPps; 174 | conn.avgInBps = avgInBps; 175 | conn.avgOutBps = avgOutBps; 176 | view.lastData[key] = conn; 177 | }); 178 | 179 | connections.sort(view.sortFunction.bind(view)); 180 | 181 | connections.forEach(function(conn) { 182 | var srcFull = conn.src + ':' + (conn.sport || '-'); 183 | var dstFull = conn.dst + ':' + (conn.dport || '-'); 184 | var dscpString = dscpToString(conn.dscp); 185 | 186 | if (view.filter && !( 187 | conn.protocol.toLowerCase().includes(view.filter) || 188 | srcFull.toLowerCase().includes(view.filter) || 189 | dstFull.toLowerCase().includes(view.filter) || 190 | dscpString.toLowerCase().includes(view.filter) 191 | )) { 192 | return; 193 | } 194 | 195 | var srcFull = conn.src + (conn.sport !== "-" ? ':' + conn.sport : ''); 196 | var dstFull = conn.dst + (conn.dport !== "-" ? ':' + conn.dport : ''); 197 | 198 | table.appendChild(E('tr', { 'class': 'tr' }, [ 199 | E('td', { 'class': 'td' }, conn.protocol.toUpperCase()), 200 | E('td', { 'class': 'td' }, srcFull), 201 | E('td', { 'class': 'td' }, dstFull), 202 | E('td', { 'class': 'td' }, dscpString), 203 | E('td', { 'class': 'td' }, 204 | E('div', {}, [ 205 | E('span', {}, _('In: ') + formatSize(conn.in_bytes)), 206 | E('br'), 207 | E('span', {}, _('Out: ') + formatSize(conn.out_bytes)) 208 | ]) 209 | ), 210 | E('td', { 'class': 'td' }, 211 | E('div', {}, [ 212 | E('span', {}, _('In: ') + conn.in_packets), 213 | E('br'), 214 | E('span', {}, _('Out: ') + conn.out_packets) 215 | ]) 216 | ), 217 | E('td', { 'class': 'td' }, 218 | E('div', {}, [ 219 | E('span', {}, _('In: ') + conn.avgInPps), 220 | E('br'), 221 | E('span', {}, _('Out: ') + conn.avgOutPps) 222 | ]) 223 | ), 224 | E('td', { 'class': 'td' }, 225 | E('div', {}, [ 226 | E('span', {}, _('In: ') + conn.maxInPps), 227 | E('br'), 228 | E('span', {}, _('Out: ') + conn.maxOutPps) 229 | ]) 230 | ), 231 | E('td', { 'class': 'td' }, 232 | E('div', {}, [ 233 | E('span', {}, _('In: ') + convertToKbps(conn.avgInBps)), 234 | E('br'), 235 | E('span', {}, _('Out: ') + convertToKbps(conn.avgOutBps)) 236 | ]) 237 | ) 238 | ])); 239 | }); 240 | view.updateSortIndicators(); 241 | }; 242 | 243 | view.updateTable(connections); 244 | this.updateSortIndicators(); 245 | 246 | poll.add(function() { 247 | return callQoSmateConntrackDSCP().then(function(result) { 248 | if (result && result.connections) { 249 | view.updateTable(Object.values(result.connections)); 250 | } else { 251 | console.error('Invalid data received:', result); 252 | } 253 | }); 254 | }, view.pollInterval); 255 | 256 | var style = E('style', {}, ` 257 | .sort-indicator { 258 | display: inline-block; 259 | width: 0; 260 | height: 0; 261 | margin-left: 5px; 262 | vertical-align: middle; 263 | } 264 | `); 265 | 266 | return E('div', { 'class': 'cbi-map' }, [ 267 | style, 268 | E('h2', _('QoSmate Connections')), 269 | E('div', { 'style': 'margin-bottom: 10px;' }, [ 270 | filterInput 271 | ]), 272 | E('div', { 'class': 'cbi-section' }, [ 273 | E('div', { 'class': 'cbi-section-node' }, [ 274 | table 275 | ]) 276 | ]) 277 | ]); 278 | }, 279 | 280 | sortTable: function(column, ev) { 281 | ev.preventDefault(); 282 | if (this.sortColumn === column) { 283 | this.sortDescending = !this.sortDescending; 284 | } else { 285 | this.sortColumn = column; 286 | this.sortDescending = true; 287 | } 288 | var connections = Object.values(this.lastData); 289 | this.updateTable(connections); 290 | this.updateSortIndicators(); 291 | }, 292 | 293 | sortFunction: function(a, b) { 294 | var aValue, bValue; 295 | 296 | switch(this.sortColumn) { 297 | case 'bytes': 298 | aValue = (a.in_bytes || 0) + (a.out_bytes || 0); 299 | bValue = (b.in_bytes || 0) + (b.out_bytes || 0); 300 | break; 301 | case 'packets': 302 | aValue = (a.in_packets || 0) + (a.out_packets || 0); 303 | bValue = (b.in_packets || 0) + (b.out_packets || 0); 304 | break; 305 | case 'avgPps': 306 | aValue = (a.avgInPps || 0) + (a.avgOutPps || 0); 307 | bValue = (b.avgInPps || 0) + (b.avgOutPps || 0); 308 | break; 309 | case 'maxPps': 310 | aValue = Math.max(a.maxInPps || 0, a.maxOutPps || 0); 311 | bValue = Math.max(b.maxInPps || 0, b.maxOutPps || 0); 312 | break; 313 | case 'avgBps': 314 | aValue = (a.avgInBps || 0) + (a.avgOutBps || 0); 315 | bValue = (b.avgInBps || 0) + (b.avgOutBps || 0); 316 | break; 317 | default: 318 | aValue = a[this.sortColumn]; 319 | bValue = b[this.sortColumn]; 320 | } 321 | 322 | if (typeof aValue === 'string') aValue = aValue.toLowerCase(); 323 | if (typeof bValue === 'string') bValue = bValue.toLowerCase(); 324 | 325 | if (aValue < bValue) return this.sortDescending ? 1 : -1; 326 | if (aValue > bValue) return this.sortDescending ? -1 : 1; 327 | return 0; 328 | }, 329 | 330 | createSortIndicator: function(column) { 331 | return E('span', { 'class': 'sort-indicator', 'data-column': column }, ''); 332 | }, 333 | 334 | updateSortIndicators: function() { 335 | var indicators = document.querySelectorAll('.sort-indicator'); 336 | indicators.forEach(function(indicator) { 337 | if (indicator.dataset.column === this.sortColumn) { 338 | indicator.textContent = this.sortDescending ? ' ▼' : ' ▲'; 339 | } else { 340 | indicator.textContent = ''; 341 | } 342 | }.bind(this)); 343 | }, 344 | 345 | handleSaveApply: null, 346 | handleSave: null, 347 | handleReset: null 348 | }); 349 | -------------------------------------------------------------------------------- /dev/luci-app-qosmate.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "luci-app-qosmate": { 4 | "description": "Grant access to QoSmate configuration", 5 | "read": { 6 | "ubus": { 7 | "luci.qosmate": [ "getConntrackDSCP", "getDscpStats" ], 8 | "luci": [ "getInitList", "setInitAction", "getInitActionStatus", "exec" ] 9 | }, 10 | "uci": [ "qosmate" ], 11 | "file": { 12 | "/etc/qosmate.sh": [ "read" ], 13 | "/etc/init.d/qosmate": [ "read", "exec" ], 14 | "/etc/hotplug.d/iface/13-qosmateHotplug": [ "read" ], 15 | "/etc/config/qosmate": [ "read" ], 16 | "/tmp/qosmate_auto_setup_output.txt": [ "read" ] 17 | } 18 | }, 19 | "write": { 20 | "ubus": { 21 | "luci": [ "setInitAction", "exec" ] 22 | }, 23 | "uci": [ "qosmate" ], 24 | "file": { 25 | "/etc/qosmate.sh": [ "write" ], 26 | "/etc/init.d/qosmate": [ "write" ], 27 | "/etc/hotplug.d/iface/13-qosmateHotplug": [ "write" ] 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /dev/luci.qosmate: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env lua 2 | 3 | local jsonc = require "luci.jsonc" 4 | 5 | -- Check if an IP address is private - not needed at the moment 6 | local function is_private_ip(ip) 7 | if not ip or ip == "" then 8 | return false 9 | end 10 | 11 | if ip:match(":") then -- IPv6 12 | -- Check for ULA (fc00::/7), link-local (fe80::/10), or loopback (::1) 13 | return ip:match("^f[cd]") or ip:match("^fe80:") or ip == "::1" 14 | else -- IPv4 15 | local octets = {ip:match("(%d+)%.(%d+)%.(%d+)%.(%d+)")} 16 | if not octets[1] then return false end 17 | local first, second = tonumber(octets[1]), tonumber(octets[2]) 18 | -- Check for private IPv4 ranges: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 19 | return (first == 10) or 20 | (first == 172 and second >= 16 and second <= 31) or 21 | (first == 192 and second == 168) 22 | end 23 | end 24 | 25 | -- Parse a single connection line from nf_conntrack 26 | local function parse_connection(line) 27 | local conn = {} 28 | conn.layer3, conn.layer4, conn.protocol, conn.timeout = line:match("(%w+)%s+(%d+)%s+(%w+)%s+(%d+)") 29 | if not (conn.layer3 and conn.layer4 and conn.protocol and conn.timeout) then 30 | return nil 31 | end 32 | 33 | if conn.protocol == "icmp" or conn.protocol == "icmpv6" then 34 | -- Handle ICMP and ICMPv6 protocols 35 | conn.src, conn.dst, conn.type, conn.code, conn.id = 36 | line:match("src=(%S+)%s+dst=(%S+)%s+type=(%d+)%s+code=(%d+)%s+id=(%d+)") 37 | conn.in_packets, conn.in_bytes = line:match("packets=(%d+)%s+bytes=(%d+)") 38 | conn.out_packets, conn.out_bytes = conn.in_packets, conn.in_bytes 39 | conn.sport, conn.dport = "-", "-" -- ICMP doesn't use ports 40 | else 41 | -- Handle other protocols (e.g., TCP, UDP) 42 | local src1, dst1, sport1, dport1, packets1, bytes1, 43 | src2, dst2, sport2, dport2, packets2, bytes2 = 44 | line:match("src=(%S+)%s+dst=(%S+)%s+sport=(%d+)%s+dport=(%d+)%s+packets=(%d+)%s+bytes=(%d+).*src=(%S+)%s+dst=(%S+)%s+sport=(%d+)%s+dport=(%d+)%s+packets=(%d+)%s+bytes=(%d+)") 45 | 46 | -- Always use the first direction as the original 47 | conn.src, conn.dst, conn.sport, conn.dport = src1, dst1, sport1, dport1 48 | conn.out_packets, conn.in_packets = tonumber(packets1), tonumber(packets2) 49 | conn.out_bytes, conn.in_bytes = tonumber(bytes1), tonumber(bytes2) 50 | end 51 | 52 | if not (conn.src and conn.dst) then 53 | return nil 54 | end 55 | 56 | -- Extract additional connection information 57 | conn.dscp = math.floor(tonumber(line:match("mark=(%d+)") or "0")) 58 | conn.use = tonumber(line:match("use=(%d+)") or "0") 59 | conn.timeout = tonumber(conn.timeout) or 0 60 | 61 | -- Determine connection state 62 | if line:match("%[ASSURED%]") then 63 | conn.state = "ASSURED" 64 | elseif line:match("%[UNREPLIED%]") then 65 | conn.state = "UNREPLIED" 66 | else 67 | conn.state = "UNKNOWN" 68 | end 69 | 70 | return conn 71 | end 72 | 73 | -- Retrieve all current connections from nf_conntrack 74 | local function get_connections() 75 | local connections = {} 76 | local f = io.open("/proc/net/nf_conntrack", "r") 77 | if not f then 78 | return connections 79 | end 80 | 81 | for line in f:lines() do 82 | local conn = parse_connection(line) 83 | if conn then 84 | local key = string.format("%s:%s:%s:%s:%s:%s", conn.layer3, conn.protocol, conn.src, conn.sport, conn.dst, conn.dport) 85 | connections[key] = conn 86 | end 87 | end 88 | f:close() 89 | 90 | return connections 91 | end 92 | 93 | -- Define RPC methods 94 | local methods = { 95 | getConntrackDSCP = { 96 | call = function() 97 | local connections = get_connections() 98 | return {result = jsonc.stringify({connections = connections})} 99 | end 100 | } 101 | } 102 | 103 | -- Handle RPC calls 104 | if arg[1] == "list" then 105 | local rv = {} 106 | for _, v in pairs(methods) do 107 | rv[_] = v.args or {} 108 | end 109 | print((jsonc.stringify(rv):gsub(":%[%]", ":{}"))) 110 | elseif arg[1] == "call" then 111 | local args = jsonc.parse(io.stdin:read("*a")) 112 | local method = methods[arg[2]] 113 | if method then 114 | local result = method.call(args) 115 | print(result.result) 116 | os.exit(result.code or 0) 117 | else 118 | print(jsonc.stringify({error = "Method not found"})) 119 | os.exit(1) 120 | end 121 | end 122 | -------------------------------------------------------------------------------- /dev/menu.d/luci-app-qosmate.json: -------------------------------------------------------------------------------- 1 | { 2 | "admin/network/qosmate": { 3 | "title": "QoSmate", 4 | "order": 70, 5 | "action": { 6 | "type": "firstchild" 7 | }, 8 | "depends": { 9 | "acl": [ "luci-app-qosmate" ], 10 | "uci": { "qosmate": true } 11 | } 12 | }, 13 | "admin/network/qosmate/settings": { 14 | "title": "Settings", 15 | "order": 10, 16 | "action": { 17 | "type": "view", 18 | "path": "qosmate/settings" 19 | } 20 | }, 21 | "admin/network/qosmate/hfsc": { 22 | "title": "HFSC", 23 | "order": 20, 24 | "action": { 25 | "type": "view", 26 | "path": "qosmate/hfsc" 27 | } 28 | }, 29 | "admin/network/qosmate/cake": { 30 | "title": "CAKE", 31 | "order": 30, 32 | "action": { 33 | "type": "view", 34 | "path": "qosmate/cake" 35 | } 36 | }, 37 | "admin/network/qosmate/advanced": { 38 | "title": "Advanced", 39 | "order": 40, 40 | "action": { 41 | "type": "view", 42 | "path": "qosmate/advanced" 43 | } 44 | }, 45 | "admin/network/qosmate/rules": { 46 | "title": "Rules", 47 | "order": 50, 48 | "action": { 49 | "type": "view", 50 | "path": "qosmate/rules" 51 | } 52 | }, 53 | "admin/network/qosmate/connections": { 54 | "title": "Connections", 55 | "order": 60, 56 | "action": { 57 | "type": "view", 58 | "path": "qosmate/connections" 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /dir_fixups.txt: -------------------------------------------------------------------------------- 1 | # all fetched files and directories *inside* directories on the left side of '=' 2 | # will be moved into directories on the right side of '=' during installation 3 | # (all of this inside the distribution directory, before copying files to permanent storage) 4 | /root/usr/share/luci/menu.d=/usr/share/luci/menu.d 5 | /root/usr/share/rpcd/acl.d=/usr/share/rpcd/acl.d 6 | /root/usr/libexec/rpcd=/usr/libexec/rpcd 7 | /htdocs/luci-static/resources/view=/www/luci-static/resources/view/qosmate 8 | -------------------------------------------------------------------------------- /file_fixups.txt: -------------------------------------------------------------------------------- 1 | # all files on the left side of '=' 2 | # will be moved to paths on the right side of '=' during installation 3 | # (all of this inside the distribution directory, before copying files to permanent storage) 4 | -------------------------------------------------------------------------------- /htdocs/luci-static/resources/view/advanced.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 'require view'; 3 | 'require form'; 4 | 'require ui'; 5 | 'require uci'; 6 | 'require rpc'; 7 | 'require fs'; 8 | 9 | var callInitAction = rpc.declare({ 10 | object: 'luci', 11 | method: 'setInitAction', 12 | params: ['name', 'action'], 13 | expect: { result: false } 14 | }); 15 | 16 | return view.extend({ 17 | handleSaveApply: function(ev) { 18 | return this.handleSave(ev) 19 | .then(() => ui.changes.apply()) 20 | .then(() => uci.load('qosmate')) 21 | .then(() => uci.get_first('qosmate', 'global', 'enabled')) 22 | .then(enabled => { 23 | if (enabled === '0') { 24 | return fs.exec_direct('/etc/init.d/qosmate', ['stop']); 25 | } else { 26 | return fs.exec_direct('/etc/init.d/qosmate', ['restart']); 27 | } 28 | }) 29 | .then(() => { 30 | ui.hideModal(); 31 | window.location.reload(); 32 | }) 33 | .catch(err => { 34 | ui.hideModal(); 35 | ui.addNotification(null, E('p', _('Failed to save settings or update QoSmate service: ') + err.message)); 36 | }); 37 | }, 38 | 39 | render: function() { 40 | var m, s, o; 41 | 42 | m = new form.Map('qosmate', _('QoSmate Advanced Settings'), _('Configure advanced settings for QoSmate.')); 43 | 44 | s = m.section(form.NamedSection, 'advanced', 'advanced', _('Advanced Settings')); 45 | s.anonymous = true; 46 | 47 | function createOption(name, title, description, placeholder, datatype) { 48 | var opt = s.option(form.Value, name, title, description); 49 | opt.datatype = datatype || 'string'; 50 | opt.rmempty = true; 51 | opt.placeholder = placeholder; 52 | 53 | if (datatype === 'uinteger') { 54 | opt.validate = function(section_id, value) { 55 | if (value === '' || value === null) return true; 56 | if (!/^\d+$/.test(value)) return _('Must be a non-negative integer or empty'); 57 | return true; 58 | }; 59 | } 60 | if (datatype === 'integer') { 61 | opt.validate = function(section_id, value) { 62 | if (value === '' || value === null) return true; 63 | if (!/^-?\d+$/.test(value)) return _('Must be an integer or empty'); 64 | return true; 65 | }; 66 | } 67 | return opt; 68 | } 69 | 70 | o = s.option(form.Flag, 'PRESERVE_CONFIG_FILES', _('Preserve Config Files'), _('Preserve configuration files during system upgrade')); 71 | o.rmempty = false; 72 | 73 | o = s.option(form.Flag, 'WASHDSCPUP', _('Wash DSCP Egress'), _('Sets DSCP to CS0 for outgoing packets after classification')); 74 | o.rmempty = false; 75 | 76 | o = s.option(form.Flag, 'WASHDSCPDOWN', _('Wash DSCP Ingress'), _('Sets DSCP to CS0 for incoming packets before classification')); 77 | o.rmempty = false; 78 | 79 | createOption('BWMAXRATIO', _('Bandwidth Max Ratio'), _('Max download/upload ratio to prevent upstream congestion'), _('Default: 20'), 'uinteger'); 80 | createOption('ACKRATE', _('ACK Rate'), _('Sets rate limit for TCP ACKs, helps prevent ACK flooding / set to 0 to disable ACK rate limit'), _('Default: 5% of UPRATE'), 'uinteger'); 81 | 82 | o = s.option(form.Flag, 'UDP_RATE_LIMIT_ENABLED', _('Enable UDP Rate Limit'), _('Downgrades UDP traffic exceeding 450 pps to lower priority')); 83 | o.rmempty = false; 84 | 85 | o = s.option(form.Flag, 'TCP_UPGRADE_ENABLED', _('Boost Low-Volume TCP Traffic'), _('Upgrade DSCP to AF42 for TCP connections with less than 150 packets per second. This can improve responsiveness for interactive TCP services like SSH, web browsing, and instant messaging.')); 86 | o.rmempty = false; 87 | o.default = '1'; 88 | 89 | o = s.option(form.Flag, 'TCP_DOWNPRIO_INITIAL_ENABLED', _('Enable Initial TCP Down-Prioritization'), _('Downgrades the first ~500ms of TCP traffic (except CS1) to CS0 to prevent initial bursts')); 90 | o.rmempty = false; 91 | o.default = '1'; 92 | 93 | o = s.option(form.Flag, 'TCP_DOWNPRIO_SUSTAINED_ENABLED', _('Enable Sustained TCP Down-Prioritization'), _('Downgrades TCP flows exceeding ~10 seconds worth of data transfer to CS1 (Bulk). Helps prevent large downloads from starving other traffic.')); 94 | o.rmempty = false; 95 | o.default = '1'; 96 | 97 | createOption('UDPBULKPORT', _('UDP Bulk Ports'), _('Specify UDP ports for bulk traffic'), _('Default: none')); 98 | createOption('TCPBULKPORT', _('TCP Bulk Ports'), _('Specify TCP ports for bulk traffic'), _('Default: none')); 99 | 100 | o = s.option(form.Value, 'MSS', _('TCP MSS'), _('Maximum Segment Size for TCP connections. This setting is only active when the upload or download bandwidth is less than 3000 kbit/s. Leave empty to use the default value. Valid range: 536-1500'), _('Default: 536'), 'uinteger'); 101 | o.placeholder = 'Default: 536'; 102 | o.validate = function(section_id, value) { 103 | if (value === '' || value === null) 104 | return true; 105 | 106 | if (!/^\d+$/.test(value)) 107 | return _('Must be a number'); 108 | 109 | let num = Number(value); 110 | if (num < 536 || num > 1500) 111 | return _('Must be between 536 and 1500'); 112 | 113 | return true; 114 | }; 115 | 116 | o = s.option(form.ListValue, 'NFT_HOOK', _('Nftables Hook'), _('Select the nftables hook point for the dscptag chain')); 117 | o.value('forward', _('forward')); 118 | o.value('postrouting', _('postrouting')); 119 | o.default = 'forward'; 120 | o.rmempty = false; 121 | 122 | createOption('NFT_PRIORITY', _('Nftables Priority'), _('Set the priority for the nftables chain. Lower values are processed earlier. Default is 0 | mangle is -150.'), _('0'), 'integer'); 123 | 124 | // Update settings 125 | s = m.section(form.NamedSection, 'global', 'global', _('Update Settings')); 126 | s.anonymous = true; 127 | 128 | // Display current update channels 129 | o = s.option(form.DummyValue, '_update_channels', _('Current Update Channels')); 130 | o.rawhtml = true; 131 | o.cfgvalue = function(section_id) { 132 | return null; 133 | }; 134 | o.write = function() {}; 135 | o.remove = function() {}; 136 | o.renderWidget = function() { 137 | return Promise.all([ 138 | fs.exec_direct('/etc/init.d/qosmate', ['check_version']) 139 | ]).then(function(res) { 140 | var output = res[0]; 141 | 142 | const backendChannelMatch = output.match(/Backend versions:[\s\S]*?Update channel: (.+)/); 143 | const frontendChannelMatch = output.match(/Frontend versions:[\s\S]*?Update channel: (.+)/); 144 | 145 | var backendChannel = backendChannelMatch ? backendChannelMatch[1].trim() : 'Unknown'; 146 | var frontendChannel = frontendChannelMatch ? frontendChannelMatch[1].trim() : 'Unknown'; 147 | 148 | var tableContainer = E('div', { 'class': 'stats-table-container' }); 149 | var table = E('table', { 'class': 'table cbi-section-table' }); 150 | 151 | var headerRow = E('tr', { 'class': 'tr table-titles' }); 152 | headerRow.appendChild(E('th', { 'class': 'th' }, _('Component'))); 153 | headerRow.appendChild(E('th', { 'class': 'th' }, _('Channel'))); 154 | table.appendChild(headerRow); 155 | 156 | var backendRow = E('tr', { 'class': 'tr' }); 157 | backendRow.appendChild(E('td', { 'class': 'td' }, _('Backend'))); 158 | backendRow.appendChild(E('td', { 'class': 'td' }, backendChannel)); 159 | table.appendChild(backendRow); 160 | 161 | var frontendRow = E('tr', { 'class': 'tr' }); 162 | frontendRow.appendChild(E('td', { 'class': 'td' }, _('Frontend'))); 163 | frontendRow.appendChild(E('td', { 'class': 'td' }, frontendChannel)); 164 | table.appendChild(frontendRow); 165 | 166 | tableContainer.appendChild(table); 167 | 168 | return E('div', {}, [ 169 | tableContainer, 170 | E('div', { 'style': 'margin-top: 10px' }, [ 171 | E('button', { 172 | 'class': 'cbi-button cbi-button-neutral', 173 | 'click': ui.createHandlerFn(this, function() { 174 | ui.showModal(_('Change Update Channel'), [ 175 | E('p', {}, _('Select the update channel for QoSmate:')), 176 | E('div', { 'class': 'cbi-value' }, [ 177 | E('div', { 'class': 'cbi-value-title' }, _('Channel')), 178 | E('div', { 'class': 'cbi-value-field' }, [ 179 | E('select', { 'id': 'change_channel', 'class': 'cbi-input-select' }, [ 180 | E('option', { 181 | 'value': 'release', 182 | 'selected': backendChannel === 'release' && frontendChannel === 'release' 183 | }, _('Release (stable)')), 184 | E('option', { 185 | 'value': 'snapshot', 186 | 'selected': backendChannel === 'snapshot' && frontendChannel === 'snapshot' 187 | }, _('Snapshot (latest from main)')) 188 | ]) 189 | ]) 190 | ]), 191 | E('div', { 'class': 'right' }, [ 192 | E('button', { 193 | 'class': 'btn', 194 | 'click': ui.hideModal 195 | }, _('Cancel')), 196 | ' ', 197 | E('button', { 198 | 'class': 'cbi-button cbi-button-positive', 199 | 'click': ui.createHandlerFn(this, function() { 200 | var channelSelect = document.querySelector('.modal [id="change_channel"]'); 201 | var selectedChannel = channelSelect ? channelSelect.value : 'release'; 202 | 203 | ui.showModal(_('Changing Update Channel'), [ 204 | E('p', { 'class': 'spinning' }, _('Please wait while the update channel is being changed...')) 205 | ]); 206 | 207 | // Need to update both components to change channel 208 | var updateArgs = ['update', '-f', '-v', selectedChannel]; 209 | 210 | console.log('Executing channel change:', '/etc/init.d/qosmate', updateArgs); 211 | 212 | return fs.exec_direct('/etc/init.d/qosmate', updateArgs) 213 | .then(function(result) { 214 | console.log('Channel change result:', result); 215 | 216 | if (result && (result.includes('error') || result.includes('Error') || result.includes('failed'))) { 217 | ui.hideModal(); 218 | ui.addNotification(null, E('p', _('Update channel change encountered issues: %s').format(result)), 'warning'); 219 | return; 220 | } 221 | 222 | ui.hideModal(); 223 | ui.addNotification(null, E('p', _('Update channel changed to %s. Reloading page...').format(selectedChannel)), 'success'); 224 | 225 | window.setTimeout(function() { 226 | location.reload(); 227 | }, 2000); 228 | }) 229 | .catch(function(err) { 230 | console.error('Channel change error:', err); 231 | ui.hideModal(); 232 | 233 | var errorMessage = _('Failed to change update channel'); 234 | if (err) { 235 | if (typeof err === 'string') { 236 | errorMessage += ': ' + err; 237 | } else if (err.message) { 238 | errorMessage += ': ' + err.message; 239 | } else { 240 | errorMessage += ': ' + JSON.stringify(err); 241 | } 242 | } 243 | 244 | ui.addNotification(null, E('p', errorMessage), 'error'); 245 | }); 246 | }) 247 | }, _('Change Channel')) 248 | ]) 249 | ]); 250 | }) 251 | }, _('Change Update Channel')) 252 | ]) 253 | ]); 254 | }); 255 | }; 256 | 257 | return m.render(); 258 | } 259 | }); 260 | -------------------------------------------------------------------------------- /htdocs/luci-static/resources/view/cake.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 'require view'; 3 | 'require form'; 4 | 'require ui'; 5 | 'require uci'; 6 | 'require rpc'; 7 | 'require fs'; 8 | 9 | var callInitAction = rpc.declare({ 10 | object: 'luci', 11 | method: 'setInitAction', 12 | params: ['name', 'action'], 13 | expect: { result: false } 14 | }); 15 | 16 | return view.extend({ 17 | handleSaveApply: function(ev) { 18 | return this.handleSave(ev) 19 | .then(() => ui.changes.apply()) 20 | .then(() => uci.load('qosmate')) 21 | .then(() => uci.get_first('qosmate', 'global', 'enabled')) 22 | .then(enabled => { 23 | if (enabled === '0') { 24 | return fs.exec_direct('/etc/init.d/qosmate', ['stop']); 25 | } else { 26 | return fs.exec_direct('/etc/init.d/qosmate', ['restart']); 27 | } 28 | }) 29 | .then(() => { 30 | ui.hideModal(); 31 | window.location.reload(); 32 | }) 33 | .catch(err => { 34 | ui.hideModal(); 35 | ui.addNotification(null, E('p', _('Failed to save settings or update QoSmate service: ') + err.message)); 36 | }); 37 | }, 38 | 39 | render: function() { 40 | var m, s, o; 41 | 42 | m = new form.Map('qosmate', _('QoSmate CAKE Settings'), _('Configure CAKE settings for QoSmate.')); 43 | 44 | s = m.section(form.NamedSection, 'cake', 'cake', _('CAKE Settings')); 45 | s.anonymous = true; 46 | 47 | function createOption(name, title, description, placeholder, datatype) { 48 | var opt = s.option(form.Value, name, title, description); 49 | opt.datatype = datatype || 'string'; 50 | opt.rmempty = true; 51 | opt.placeholder = placeholder; 52 | 53 | if (datatype === 'uinteger') { 54 | opt.validate = function(section_id, value) { 55 | if (value === '' || value === null) return true; 56 | if (!/^\d+$/.test(value)) return _('Must be a non-negative integer or empty'); 57 | return true; 58 | }; 59 | } 60 | return opt; 61 | } 62 | 63 | o = s.option(form.ListValue, 'COMMON_LINK_PRESETS', _('Common Link Presets'), _('Select common link presets')); 64 | o.value('raw', _('Raw (No overhead compensation)')); 65 | o.value('conservative', _('Conservative (48 bytes overhead + ATM)')); 66 | o.value('ethernet', _('Ethernet')); 67 | o.value('docsis', _('DOCSIS cable')); 68 | o.value('pppoa-vcmux', _('PPPoA VC-Mux')); 69 | o.value('pppoa-llc', _('PPPoA LLC')); 70 | o.value('pppoe-vcmux', _('PPPoE VC-Mux')); 71 | o.value('pppoe-llcsnap', _('PPPoE LLC-SNAP')); 72 | o.value('bridged-vcmux', _('Bridged VC-Mux')); 73 | o.value('bridged-llcsnap', _('Bridged LLC-SNAP')); 74 | o.value('ipoa-vcmux', _('IPoA VC-Mux')); 75 | o.value('ipoa-llcsnap', _('IPoA LLC-SNAP')); 76 | o.value('pppoe-ptm', _('PPPoE PTM')); 77 | o.value('bridged-ptm', _('Bridged PTM')); 78 | o.default = 'ethernet'; 79 | 80 | createOption('OVERHEAD', _('Overhead'), _('Set the overhead'), _('Default: based on preset')); 81 | createOption('MPU', _('MPU'), _('Minimum packet size CAKE will account for'), _('Default: based on preset'), 'uinteger'); 82 | createOption('LINK_COMPENSATION', _('Link Compensation'), _('Set the link compensation'), _('Default: based on preset')); 83 | createOption('ETHER_VLAN_KEYWORD', _('Ether VLAN Keyword'), _('Set the Ether VLAN keyword'), _('Default: none')); 84 | 85 | o = s.option(form.ListValue, 'PRIORITY_QUEUE_INGRESS', _('Priority Queue (Ingress)'), _('Sets CAKE\'s diffserv mode for incoming traffic')); 86 | o.value('diffserv3', _('Diffserv 3-tier priority')); 87 | o.value('diffserv4', _('Diffserv 4-tier priority')); 88 | o.value('diffserv8', _('Diffserv 8-tier priority')); 89 | o.default = 'diffserv4'; 90 | 91 | o = s.option(form.ListValue, 'PRIORITY_QUEUE_EGRESS', _('Priority Queue (Egress)'), _('Sets CAKE\'s diffserv mode for outgoing traffic')); 92 | o.value('diffserv3', _('Diffserv 3-tier priority')); 93 | o.value('diffserv4', _('Diffserv 4-tier priority')); 94 | o.value('diffserv8', _('Diffserv 8-tier priority')); 95 | o.default = 'diffserv4'; 96 | 97 | o = s.option(form.Flag, 'HOST_ISOLATION', _('Host Isolation'), _('Applies fairness first by host, then by flow(dual-srchost/dual-dsthost)')); 98 | o.rmempty = false; 99 | o.default = '1'; 100 | 101 | o = s.option(form.Flag, 'NAT_INGRESS', _('NAT (Ingress)'), _('Enable NAT lookup for ingress')); 102 | o.rmempty = false; 103 | o.default = '1'; 104 | 105 | o = s.option(form.Flag, 'NAT_EGRESS', _('NAT (Egress)'), _('Enable NAT lookup for egress')); 106 | o.rmempty = false; 107 | o.default = '1'; 108 | 109 | o = s.option(form.ListValue, 'ACK_FILTER_EGRESS', _('ACK Filter (Egress)'), 110 | _('Set ACK filter for egress. Auto enables filtering if download/upload ratio ≥ 15.')); 111 | o.value('auto', _('Auto')); 112 | o.value('1', _('Enable')); 113 | o.value('0', _('Disable')); 114 | o.default = 'auto'; 115 | 116 | createOption('RTT', _('RTT'), _('Set the Round Trip Time'), _('Default: auto'), 'uinteger'); 117 | 118 | o = s.option(form.Flag, 'AUTORATE_INGRESS', _('Autorate (Ingress)'), _('Enable autorate for ingress')); 119 | o.rmempty = false; 120 | o.default = '0'; 121 | 122 | createOption('EXTRA_PARAMETERS_INGRESS', _('Extra Parameters (Ingress)'), _('Set extra parameters for ingress'), _('Default: none')); 123 | createOption('EXTRA_PARAMETERS_EGRESS', _('Extra Parameters (Egress)'), _('Set extra parameters for egress'), _('Default: none')); 124 | 125 | return m.render(); 126 | } 127 | }); 128 | -------------------------------------------------------------------------------- /htdocs/luci-static/resources/view/connections.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 'require view'; 3 | 'require poll'; 4 | 'require rpc'; 5 | 'require ui'; 6 | 'require form'; 7 | 8 | var callQoSmateConntrackDSCP = rpc.declare({ 9 | object: 'luci.qosmate', 10 | method: 'getConntrackDSCP', 11 | expect: { } 12 | }); 13 | 14 | var dscpToString = function(mark) { 15 | var dscp = mark & 0x3F; 16 | var dscpMap = { 17 | 0: 'CS0', 18 | 8: 'CS1', 19 | 10: 'AF11', 20 | 12: 'AF12', 21 | 14: 'AF13', 22 | 16: 'CS2', 23 | 18: 'AF21', 24 | 20: 'AF22', 25 | 22: 'AF23', 26 | 24: 'CS3', 27 | 26: 'AF31', 28 | 28: 'AF32', 29 | 30: 'AF33', 30 | 32: 'CS4', 31 | 34: 'AF41', 32 | 36: 'AF42', 33 | 38: 'AF43', 34 | 40: 'CS5', 35 | 46: 'EF', 36 | 48: 'CS6', 37 | 56: 'CS7' 38 | }; 39 | return dscpMap[dscp] || dscp.toString(); 40 | }; 41 | 42 | var formatSize = function(bytes) { 43 | var sizes = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB']; 44 | if (bytes == 0) return '0 B'; 45 | var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024))); 46 | return Math.round(bytes / Math.pow(1024, i) * 100) / 100 + ' ' + sizes[i]; 47 | }; 48 | 49 | var convertToKbps = function(bytesPerSecond) { 50 | return (bytesPerSecond * 8 / 1000).toFixed(2) + ' Kbit/s'; 51 | }; 52 | 53 | return view.extend({ 54 | pollInterval: 1, 55 | lastData: {}, 56 | filter: '', 57 | sortColumn: 'bytes', 58 | sortDescending: true, 59 | connectionHistory: {}, 60 | historyLength: 10, 61 | lastUpdateTime: 0, 62 | autoRefresh: true, 63 | refreshTimeout: null, 64 | hasPolledOnce: false, 65 | 66 | load: function() { 67 | return Promise.all([ 68 | callQoSmateConntrackDSCP() 69 | ]); 70 | }, 71 | 72 | render: function(data) { 73 | var view = this; 74 | var connections = []; 75 | if (data[0] && data[0].connections) { 76 | connections = Object.values(data[0].connections); 77 | } 78 | 79 | var filterInput = E('input', { 80 | 'type': 'text', 81 | 'placeholder': _('Filter by: IP IP:Port Port Protocol DSCP'), 82 | 'style': 'margin-bottom: 10px; width: 300px;', 83 | 'value': view.filter 84 | }); 85 | 86 | filterInput.addEventListener('input', function(ev) { 87 | view.filter = ev.target.value.toLowerCase(); 88 | view.updateTable(connections); 89 | }); 90 | 91 | var table = E('table', { 'class': 'table cbi-section-table', 'id': 'qosmate_connections' }, [ 92 | E('tr', { 'class': 'tr table-titles' }, [ 93 | E('th', { 'class': 'th' }, E('a', { 'href': '#', 'click': this.sortTable.bind(this, 'protocol') }, [ _('Protocol'), this.createSortIndicator('protocol') ])), 94 | E('th', { 'class': 'th' }, E('a', { 'href': '#', 'click': this.sortTable.bind(this, 'src') }, [ _('Source'), this.createSortIndicator('src') ])), 95 | E('th', { 'class': 'th' }, E('a', { 'href': '#', 'click': this.sortTable.bind(this, 'dst') }, [ _('Destination'), this.createSortIndicator('dst') ])), 96 | E('th', { 'class': 'th' }, E('a', { 'href': '#', 'click': this.sortTable.bind(this, 'dscp') }, [ _('DSCP'), this.createSortIndicator('dscp') ])), 97 | E('th', { 'class': 'th' }, E('a', { 'href': '#', 'click': this.sortTable.bind(this, 'bytes') }, [ _('Bytes'), this.createSortIndicator('bytes') ])), 98 | E('th', { 'class': 'th' }, E('a', { 'href': '#', 'click': this.sortTable.bind(this, 'packets') }, [ _('Packets'), this.createSortIndicator('packets') ])), 99 | E('th', { 'class': 'th' }, E('a', { 'href': '#', 'click': this.sortTable.bind(this, 'avgPps') }, [ _('Avg PPS'), this.createSortIndicator('avgPps') ])), 100 | E('th', { 'class': 'th' }, E('a', { 'href': '#', 'click': this.sortTable.bind(this, 'maxPps') }, [ _('Max PPS'), this.createSortIndicator('maxPps') ])), 101 | E('th', { 'class': 'th' }, E('a', { 'href': '#', 'click': this.sortTable.bind(this, 'avgBps') }, [ _('Avg BPS'), this.createSortIndicator('avgBps') ])) 102 | ]) 103 | ]); 104 | 105 | view.updateTable = function(connections) { 106 | // Remove all rows except the header 107 | while (table.rows.length > 1) { 108 | table.deleteRow(1); 109 | } 110 | 111 | var currentTime = Date.now() / 1000; 112 | var timeDiff = currentTime - view.lastUpdateTime; 113 | view.lastUpdateTime = currentTime; 114 | 115 | connections.forEach(function(conn) { 116 | var key = conn.layer3 + conn.protocol + conn.src + conn.sport + conn.dst + conn.dport; 117 | var lastConn = view.lastData[key]; 118 | 119 | if (!view.connectionHistory[key]) { 120 | view.connectionHistory[key] = { 121 | inPpsHistory: [], 122 | outPpsHistory: [], 123 | inBpsHistory: [], 124 | outBpsHistory: [], 125 | lastInPackets: conn.in_packets, 126 | lastOutPackets: conn.out_packets, 127 | lastInBytes: conn.in_bytes, 128 | lastOutBytes: conn.out_bytes, 129 | lastTimestamp: currentTime 130 | }; 131 | } 132 | 133 | var history = view.connectionHistory[key]; 134 | var instantInPps = 0, instantOutPps = 0, instantInBps = 0, instantOutBps = 0; 135 | 136 | if (lastConn && timeDiff > 0) { 137 | var inPacketDiff = Math.max(0, conn.in_packets - history.lastInPackets); 138 | var outPacketDiff = Math.max(0, conn.out_packets - history.lastOutPackets); 139 | var inBytesDiff = Math.max(0, conn.in_bytes - history.lastInBytes); 140 | var outBytesDiff = Math.max(0, conn.out_bytes - history.lastOutBytes); 141 | 142 | instantInPps = Math.round(inPacketDiff / timeDiff); 143 | instantOutPps = Math.round(outPacketDiff / timeDiff); 144 | instantInBps = Math.round(inBytesDiff / timeDiff); 145 | instantOutBps = Math.round(outBytesDiff / timeDiff); 146 | 147 | history.inPpsHistory.push(instantInPps); 148 | history.outPpsHistory.push(instantOutPps); 149 | history.inBpsHistory.push(instantInBps); 150 | history.outBpsHistory.push(instantOutBps); 151 | 152 | if (history.inPpsHistory.length > view.historyLength) { 153 | history.inPpsHistory.shift(); 154 | history.outPpsHistory.shift(); 155 | history.inBpsHistory.shift(); 156 | history.outBpsHistory.shift(); 157 | } 158 | } 159 | 160 | history.lastInPackets = conn.in_packets; 161 | history.lastOutPackets = conn.out_packets; 162 | history.lastInBytes = conn.in_bytes; 163 | history.lastOutBytes = conn.out_bytes; 164 | history.lastTimestamp = currentTime; 165 | 166 | var avgInPps = Math.round(history.inPpsHistory.reduce((a, b) => a + b, 0) / history.inPpsHistory.length) || 0; 167 | var avgOutPps = Math.round(history.outPpsHistory.reduce((a, b) => a + b, 0) / history.outPpsHistory.length) || 0; 168 | var avgInBps = Math.round(history.inBpsHistory.reduce((a, b) => a + b, 0) / history.inBpsHistory.length) || 0; 169 | var avgOutBps = Math.round(history.outBpsHistory.reduce((a, b) => a + b, 0) / history.outBpsHistory.length) || 0; 170 | var maxInPps = Math.max(...history.inPpsHistory, 0); 171 | var maxOutPps = Math.max(...history.outPpsHistory, 0); 172 | 173 | conn.avgInPps = avgInPps; 174 | conn.avgOutPps = avgOutPps; 175 | conn.maxInPps = maxInPps; 176 | conn.maxOutPps = maxOutPps; 177 | conn.avgInBps = avgInBps; 178 | conn.avgOutBps = avgOutBps; 179 | view.lastData[key] = conn; 180 | }); 181 | 182 | connections.sort(view.sortFunction.bind(view)); 183 | 184 | connections.forEach(function(conn) { 185 | if (view.filter) { 186 | // Split the filter string by whitespace to get individual tokens 187 | var tokens = view.filter.split(/\s+/).map(function(token) { 188 | return token.trim().toLowerCase(); 189 | }); 190 | 191 | // Collect the relevant fields for matching 192 | var dscpString = dscpToString(conn.dscp); 193 | var srcFull = conn.src + (conn.sport !== "-" ? ':' + conn.sport : ''); 194 | var dstFull = conn.dst + (conn.dport !== "-" ? ':' + conn.dport : ''); 195 | var fields = [ 196 | conn.protocol.toLowerCase(), 197 | srcFull.toLowerCase(), 198 | dstFull.toLowerCase(), 199 | dscpString.toLowerCase() 200 | ]; 201 | 202 | // Each token must match at least one field (AND logic across tokens, OR logic across fields) 203 | var pass = tokens.every(function(t) { 204 | return fields.some(function(field) { 205 | return field.includes(t); 206 | }); 207 | }); 208 | if (!pass) { 209 | return; 210 | } 211 | } 212 | var srcFull = conn.src + ':' + (conn.sport || '-'); 213 | var dstFull = conn.dst + ':' + (conn.dport || '-'); 214 | var dscpString = dscpToString(conn.dscp); 215 | 216 | table.appendChild(E('tr', { 'class': 'tr' }, [ 217 | E('td', { 'class': 'td' }, conn.protocol.toUpperCase()), 218 | E('td', { 'class': 'td' }, srcFull), 219 | E('td', { 'class': 'td' }, dstFull), 220 | E('td', { 'class': 'td' }, dscpString), 221 | E('td', { 'class': 'td' }, 222 | E('div', {}, [ 223 | E('span', {}, _('In: ') + formatSize(conn.in_bytes)), 224 | E('br'), 225 | E('span', {}, _('Out: ') + formatSize(conn.out_bytes)) 226 | ]) 227 | ), 228 | E('td', { 'class': 'td' }, 229 | E('div', {}, [ 230 | E('span', {}, _('In: ') + conn.in_packets), 231 | E('br'), 232 | E('span', {}, _('Out: ') + conn.out_packets) 233 | ]) 234 | ), 235 | E('td', { 'class': 'td' }, 236 | E('div', {}, [ 237 | E('span', {}, _('In: ') + conn.avgInPps), 238 | E('br'), 239 | E('span', {}, _('Out: ') + conn.avgOutPps) 240 | ]) 241 | ), 242 | E('td', { 'class': 'td' }, 243 | E('div', {}, [ 244 | E('span', {}, _('In: ') + conn.maxInPps), 245 | E('br'), 246 | E('span', {}, _('Out: ') + conn.maxOutPps) 247 | ]) 248 | ), 249 | E('td', { 'class': 'td' }, 250 | E('div', {}, [ 251 | E('span', {}, _('In: ') + convertToKbps(conn.avgInBps)), 252 | E('br'), 253 | E('span', {}, _('Out: ') + convertToKbps(conn.avgOutBps)) 254 | ]) 255 | ) 256 | ])); 257 | }); 258 | view.updateSortIndicators(); 259 | }; 260 | 261 | view.updateTable(connections); 262 | this.updateSortIndicators(); 263 | 264 | // Trigger the adaptive polling: 265 | adaptivePoll(view); 266 | 267 | var style = E('style', {}, ` 268 | .sort-indicator { 269 | display: inline-block; 270 | width: 0; 271 | height: 0; 272 | margin-left: 5px; 273 | vertical-align: middle; 274 | } 275 | .table-wrapper { 276 | overflow-x: auto; 277 | max-width: 100%; 278 | } 279 | .cbi-section-table { 280 | min-width: 100%; 281 | font-size: 0.8rem; 282 | } 283 | .cbi-section-table td, .cbi-section-table th { 284 | white-space: nowrap; 285 | overflow: hidden; 286 | text-overflow: ellipsis; 287 | max-width: 150px; 288 | padding: 0.3rem; 289 | } 290 | @media screen and (max-width: 600px) { 291 | .cbi-section-table td:nth-child(5), 292 | .cbi-section-table th:nth-child(5), 293 | .cbi-section-table td:nth-child(6), 294 | .cbi-section-table th:nth-child(6) { 295 | display: none; 296 | } 297 | } 298 | /* Styles for different zoom levels */ 299 | .cbi-section-table.zoom-100 { font-size: 1rem !important; } 300 | .cbi-section-table.zoom-90 { font-size: 0.9rem !important; } 301 | .cbi-section-table.zoom-80 { font-size: 0.8rem !important; } 302 | .cbi-section-table.zoom-70 { font-size: 0.7rem !important; } 303 | .cbi-section-table.zoom-60 { font-size: 0.6rem !important; } 304 | .cbi-section-table.zoom-50 { font-size: 0.5rem !important; } 305 | 306 | /* Adjust padding for zoomed states */ 307 | .cbi-section-table[class*="zoom-"] td, 308 | .cbi-section-table[class*="zoom-"] th { 309 | padding: 0.2rem !important; 310 | } 311 | 312 | /* Style for the zoom select */ 313 | .zoom-select { 314 | margin-left: 10px; 315 | padding: 2px 5px; 316 | } 317 | `); 318 | 319 | // Create zoom select 320 | var zoomSelect = E('select', { 321 | 'class': 'zoom-select', 322 | 'change': function(ev) { 323 | var table = document.getElementById('qosmate_connections'); 324 | // Remove all zoom classes 325 | table.classList.remove('zoom-100', 'zoom-90', 'zoom-80', 'zoom-70', 'zoom-60', 'zoom-50'); 326 | // Add selected zoom class 327 | table.classList.add(ev.target.value); 328 | } 329 | }, [ 330 | E('option', { 'value': 'zoom-100' }, _('100%')), 331 | E('option', { 'value': 'zoom-90' }, _('90%')), 332 | E('option', { 'value': 'zoom-80' }, _('80%')), 333 | E('option', { 'value': 'zoom-70' }, _('70%')), 334 | E('option', { 'value': 'zoom-60' }, _('60%')), 335 | E('option', { 'value': 'zoom-50' }, _('50%')) 336 | ]); 337 | 338 | // Display the current polling interval. 339 | var pollIntervalDisplay = E('span', { 340 | 'id': 'poll_interval_display', 341 | 'style': 'margin-left: 10px;' 342 | }, _('Polling Interval: ') + this.pollInterval + ' s'); 343 | 344 | // Include pollIntervalDisplay in the top container 345 | return E('div', { 'class': 'cbi-map' }, [ 346 | style, 347 | E('h2', _('QoSmate Connections')), 348 | E('div', { 'style': 'margin-bottom: 10px;' }, [ 349 | filterInput, 350 | ' ', // Space between elements. 351 | E('span', _('Zoom:')), 352 | zoomSelect, 353 | pollIntervalDisplay, 354 | ' ', // Space between elements. 355 | E('button', { 356 | 'type': 'button', 357 | 'style': 'margin-left: 10px;', 358 | 'click': function(ev) { 359 | if (view.autoRefresh) { 360 | clearTimeout(view.refreshTimeout); 361 | view.autoRefresh = false; 362 | this.textContent = _('Resume'); 363 | } else { 364 | view.autoRefresh = true; 365 | this.textContent = _('Pause'); 366 | adaptivePoll(view); 367 | } 368 | } 369 | }, _('Pause')) 370 | ]), 371 | E('div', { 'class': 'cbi-section' }, [ 372 | E('div', { 'class': 'cbi-section-node' }, [ 373 | table 374 | ]) 375 | ]) 376 | ]); 377 | }, 378 | 379 | sortTable: function(column, ev) { 380 | ev.preventDefault(); 381 | if (this.sortColumn === column) { 382 | this.sortDescending = !this.sortDescending; 383 | } else { 384 | this.sortColumn = column; 385 | this.sortDescending = true; 386 | } 387 | 388 | // Defer sorting + table update to reduce blocking in click event handler 389 | var view = this; 390 | setTimeout(function() { 391 | var connections = Object.values(view.lastData); 392 | view.updateTable(connections); 393 | view.updateSortIndicators(); 394 | }, 0); 395 | }, 396 | 397 | sortFunction: function(a, b) { 398 | var aValue, bValue; 399 | 400 | switch(this.sortColumn) { 401 | case 'bytes': 402 | aValue = (a.in_bytes || 0) + (a.out_bytes || 0); 403 | bValue = (b.in_bytes || 0) + (b.out_bytes || 0); 404 | break; 405 | case 'packets': 406 | aValue = (a.in_packets || 0) + (a.out_packets || 0); 407 | bValue = (b.in_packets || 0) + (b.out_packets || 0); 408 | break; 409 | case 'avgPps': 410 | aValue = (a.avgInPps || 0) + (a.avgOutPps || 0); 411 | bValue = (b.avgInPps || 0) + (b.avgOutPps || 0); 412 | break; 413 | case 'maxPps': 414 | aValue = Math.max(a.maxInPps || 0, a.maxOutPps || 0); 415 | bValue = Math.max(b.maxInPps || 0, b.maxOutPps || 0); 416 | break; 417 | case 'avgBps': 418 | aValue = (a.avgInBps || 0) + (a.avgOutBps || 0); 419 | bValue = (b.avgInBps || 0) + (b.avgOutBps || 0); 420 | break; 421 | default: 422 | aValue = a[this.sortColumn]; 423 | bValue = b[this.sortColumn]; 424 | } 425 | 426 | if (typeof aValue === 'string') aValue = aValue.toLowerCase(); 427 | if (typeof bValue === 'string') bValue = bValue.toLowerCase(); 428 | 429 | if (aValue < bValue) return this.sortDescending ? 1 : -1; 430 | if (aValue > bValue) return this.sortDescending ? -1 : 1; 431 | return 0; 432 | }, 433 | 434 | createSortIndicator: function(column) { 435 | return E('span', { 'class': 'sort-indicator', 'data-column': column }, ''); 436 | }, 437 | 438 | updateSortIndicators: function() { 439 | var indicators = document.querySelectorAll('.sort-indicator'); 440 | indicators.forEach(function(indicator) { 441 | if (indicator.dataset.column === this.sortColumn) { 442 | indicator.textContent = this.sortDescending ? ' ▼' : ' ▲'; 443 | } else { 444 | indicator.textContent = ''; 445 | } 446 | }.bind(this)); 447 | }, 448 | 449 | handleSaveApply: null, 450 | handleSave: null, 451 | handleReset: null 452 | }); 453 | 454 | // Adaptive polling function that measures response time and adjusts the polling interval. 455 | function adaptivePoll(view) { 456 | if (!view.autoRefresh) { 457 | return; // Do not schedule a new poll if auto-refresh is paused 458 | } 459 | var startTime = Date.now(); 460 | callQoSmateConntrackDSCP().then(function(result) { 461 | var responseTime = Date.now() - startTime; 462 | // Adjust the polling interval based on response time. 463 | if (!view.hasPolledOnce) { 464 | view.pollInterval = 3; 465 | view.hasPolledOnce = true; 466 | } else if (responseTime > 2000) { // If response time exceeds 2000ms, increase interval. 467 | view.pollInterval = Math.min(view.pollInterval + 1, 10); // Max poll interval of 10 seconds. 468 | } else if (responseTime < 1000 && view.pollInterval > 1) { // If response time is less than 1000ms and poll interval is greater than 1 second, decrease interval. 469 | view.pollInterval = Math.max(view.pollInterval - 1, 1); // Min poll interval of 1 second. 470 | } 471 | // Update the polling interval display in the UI. 472 | var pollDisplay = document.getElementById('poll_interval_display'); 473 | if (pollDisplay) { 474 | pollDisplay.textContent = _('Polling Interval: ') + view.pollInterval + ' s'; 475 | } 476 | if (result && result.connections) { 477 | view.updateTable(Object.values(result.connections)); 478 | } else { 479 | console.error('Invalid data received:', result); 480 | } 481 | }).finally(function() { 482 | // Schedule the next poll only if auto-refresh is not paused 483 | if (view.autoRefresh) { 484 | view.refreshTimeout = setTimeout(function() { 485 | adaptivePoll(view); 486 | }, view.pollInterval * 1000); 487 | } 488 | }); 489 | } 490 | -------------------------------------------------------------------------------- /htdocs/luci-static/resources/view/custom_rules.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 'require view'; 3 | 'require form'; 4 | 'require ui'; 5 | 'require uci'; 6 | 'require fs'; 7 | 'require rpc'; 8 | 9 | var callInitAction = rpc.declare({ 10 | object: 'luci', 11 | method: 'setInitAction', 12 | params: ['name', 'action'], 13 | expect: { result: false } 14 | }); 15 | 16 | return view.extend({ 17 | handleSaveApply: function(ev) { 18 | return this.handleSave(ev) 19 | .then(() => { 20 | return ui.changes.apply(); 21 | }) 22 | .then(() => { 23 | return callInitAction('qosmate', 'restart'); 24 | }) 25 | .then(() => { 26 | ui.addNotification(null, E('p', _('Custom rules have been saved and applied.')), 'success'); 27 | }) 28 | .catch((err) => { 29 | ui.addNotification(null, E('p', _('Failed to save settings or restart QoSmate: ') + err.message), 'error'); 30 | }); 31 | }, 32 | 33 | load: function() { 34 | return Promise.all([ 35 | fs.read('/etc/qosmate.d/custom_rules.nft') 36 | .then(content => { 37 | content = content.replace(/^table\s+inet\s+qosmate_custom\s*{/, ''); 38 | content = content.replace(/}\s*$/, ''); 39 | return content.trim(); 40 | }) 41 | .catch(() => ''), 42 | fs.read('/tmp/qosmate_custom_rules_validation.txt') 43 | .catch(() => '') 44 | ]); 45 | }, 46 | 47 | render: function([customRules, validationResult]) { 48 | var m, s, o; 49 | 50 | m = new form.Map('qosmate', _('QoSmate Custom Rules'), 51 | _('Define custom nftables rules for advanced traffic control.')); 52 | 53 | s = m.section(form.NamedSection, 'custom_rules', 'qosmate', _('Custom Rules')); 54 | s.anonymous = true; 55 | s.addremove = false; 56 | 57 | o = s.option(form.Button, '_erase', _('Erase Rules')); 58 | o.inputstyle = 'remove'; 59 | o.inputtitle = _('Erase Custom Rules'); 60 | o.onclick = function(ev) { 61 | return ui.showModal(_('Erase Custom Rules'), [ 62 | E('p', _('Are you sure you want to erase all custom rules? This action cannot be undone.')), 63 | E('div', { 'class': 'right' }, [ 64 | E('button', { 65 | 'class': 'btn', 66 | 'click': ui.hideModal 67 | }, _('Cancel')), 68 | ' ', 69 | E('button', { 70 | 'class': 'btn cbi-button-negative', 71 | 'click': ui.createHandlerFn(this, function() { 72 | var textarea = document.querySelector('textarea[name="cbid.qosmate.custom_rules.custom_rules"]'); 73 | if (textarea) { 74 | textarea.value = ''; 75 | } 76 | 77 | return fs.remove('/etc/qosmate.d/custom_rules.nft') 78 | .then(() => { 79 | return ui.changes.apply(); 80 | }) 81 | .then(() => { 82 | return callInitAction('qosmate', 'restart'); 83 | }) 84 | .then(() => { 85 | ui.hideModal(); 86 | ui.addNotification(null, E('p', _('Custom rules have been erased and changes applied.')), 'success'); 87 | window.setTimeout(function() { 88 | window.location.reload(); 89 | }, 2000); 90 | }) 91 | .catch((err) => { 92 | ui.hideModal(); 93 | ui.addNotification(null, E('p', _('Failed to erase custom rules or apply changes: ') + err.message), 'error'); 94 | }); 95 | }) 96 | }, _('Erase')) 97 | ]) 98 | ]); 99 | }; 100 | 101 | o = s.option(form.TextValue, 'custom_rules', _('Custom nftables Rules')); 102 | o.rows = 20; 103 | o.wrap = 'off'; 104 | o.rmempty = true; 105 | o.monospace = true; 106 | o.datatype = 'string'; 107 | o.description = _('Enter your custom nftables rules here. The "table inet qosmate_custom { ... }" wrapper will be added automatically.'); 108 | o.load = function(section_id) { 109 | return customRules; 110 | }; 111 | o.write = function(section_id, formvalue) { 112 | // Prepare the new custom rules (only the table definition) 113 | const newRules = `table inet qosmate_custom { 114 | ${formvalue.trim()} 115 | }`; 116 | 117 | // Delete the existing table before applying new rules 118 | // If deletion fails (table doesn't exist), ignore the error 119 | return fs.exec('nft', ['delete', 'table', 'inet', 'qosmate_custom']) 120 | .catch(() => { /* ignore deletion error */ }) 121 | .then(() => fs.write('/etc/qosmate.d/custom_rules.nft', newRules)) 122 | .then(() => fs.exec('/etc/init.d/qosmate', ['validate_custom_rules'])) 123 | .then(() => fs.read('/tmp/qosmate_custom_rules_validation.txt')) 124 | .then((result) => { 125 | if (result.includes('Custom rules validation successful.')) { 126 | ui.addNotification(null, E('p', _('Custom rules validation successful.')), 'success'); 127 | } else { 128 | ui.addNotification(null, E('p', _('Custom rules validation failed. Please check the validation result below.')), 'warning'); 129 | } 130 | }); 131 | }; 132 | 133 | o = s.option(form.DummyValue, '_validation_result', _('Validation Result')); 134 | o.rawhtml = true; 135 | o.default = validationResult 136 | ? E('div', { 'class': 'cbi-value-field' }, 137 | E('div', { 'class': 'cbi-section-node', 'style': 'background-color:#f9f9f9; border:1px solid #e5e5e5; border-radius:3px; padding:10px; margin-top:5px; min-width: 700px' }, 138 | E('pre', { 'style': 'white-space:pre-wrap; word-break:break-word;' }, validationResult) 139 | ) 140 | ) 141 | : _('No validation performed yet'); 142 | 143 | o = s.option(form.Button, '_validate', _('Validate Rules')); 144 | o.inputstyle = 'apply'; 145 | o.inputtitle = _('Validate'); 146 | o.onclick = function(ev) { 147 | var map = this.map; 148 | var section_id = 'custom_rules'; // Assuming this is the correct section_id 149 | 150 | var customRulesTextarea = document.getElementById('widget.cbid.qosmate.' + section_id + '.custom_rules'); 151 | if (!customRulesTextarea) { 152 | ui.addNotification(null, E('p', _('Error: Could not find custom rules textarea')), 'error'); 153 | return; 154 | } 155 | 156 | var currentRules = customRulesTextarea.value; 157 | var fullContent = `table inet qosmate_custom {\n${currentRules.trim()}\n}`; 158 | 159 | ui.showModal(_('Validating Rules'), [ 160 | E('p', { 'class': 'spinning' }, _('Please wait while the rules are being validated...')) 161 | ]); 162 | 163 | return fs.write('/etc/qosmate.d/custom_rules.nft', fullContent) 164 | .then(() => { 165 | return fs.exec('/etc/init.d/qosmate', ['validate_custom_rules']); 166 | }) 167 | .then(() => { 168 | return fs.read('/tmp/qosmate_custom_rules_validation.txt'); 169 | }) 170 | .then((result) => { 171 | ui.hideModal(); 172 | if (result.includes('Custom rules validation successful.')) { 173 | ui.addNotification(null, E('p', _('Custom rules validation successful.')), 'success'); 174 | } else { 175 | ui.addNotification(null, E('p', _('Custom rules validation failed. Please check the validation result below.')), 'warning'); 176 | } 177 | var validationResultElement = document.getElementById('cbid.qosmate.custom_rules._validation_result'); 178 | if (validationResultElement) { 179 | validationResultElement.innerHTML = E('pre', {}, result).outerHTML; 180 | } 181 | ui.showModal(_('Finalizing Validation'), [ 182 | E('p', { 'class': 'spinning' }, _('Finalizing validation results, please wait...')) 183 | ]); 184 | 185 | setTimeout(function() { 186 | window.location.reload(); 187 | }, 2000); 188 | }) 189 | .catch((err) => { 190 | ui.hideModal(); 191 | ui.addNotification(null, E('p', _('Error during validation: ') + err), 'error'); 192 | 193 | ui.showModal(_('Finalizing Validation'), [ 194 | E('p', { 'class': 'spinning' }, _('Finalizing validation results, please wait...')) 195 | ]); 196 | 197 | setTimeout(function() { 198 | window.location.reload(); 199 | }, 2000); 200 | }); 201 | }; 202 | 203 | o = s.option(form.DummyValue, '_rules_info', _('Rules Information')); 204 | o.rawhtml = true; 205 | o.default = '
' + 206 | '

' + _('Example rules:') + '

' + 207 | '
' +
208 |                 'chain ingress {\n' +
209 |                 '    type filter hook ingress device eth1 priority -500; policy accept;\n' +
210 |                 '    iif eth1 counter ip dscp set cs0 comment "Wash all ISP DSCP marks to CS0 (IPv4)"\n' +
211 |                 '    iif eth1 counter ip6 dscp set cs0 comment "Wash all ISP DSCP marks to CS0 (IPv6)"\n' +
212 |                 '}\n\n' +
213 |                 'chain forward {\n' +
214 |                 '    type filter hook forward priority 0; policy accept;\n' +
215 |                 '    # Limit and mark high-rate TCP traffic from specific IP\n' +
216 |                 '    ip saddr 192.168.138.100 tcp flags & (fin|syn|rst|ack) != 0\n' +
217 |                 '    limit rate over 300/second burst 300 packets\n' +
218 |                 '    counter ip dscp set cs1\n' +
219 |                 '    comment "Mark TCP traffic from 192.168.138.100 exceeding 300 pps as CS1"\n' +
220 |                 '}\n' +
221 |                 '
' + 222 | '

' + _('Warning:') + ' ' + _('Incorrect rules can disrupt network functionality. Use with caution.') + '

' + 223 | '
'; 224 | 225 | return m.render(); 226 | } 227 | }); 228 | -------------------------------------------------------------------------------- /htdocs/luci-static/resources/view/hfsc.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 'require view'; 3 | 'require form'; 4 | 'require ui'; 5 | 'require uci'; 6 | 'require rpc'; 7 | 'require fs'; 8 | 9 | var callInitAction = rpc.declare({ 10 | object: 'luci', 11 | method: 'setInitAction', 12 | params: ['name', 'action'], 13 | expect: { result: false } 14 | }); 15 | 16 | return view.extend({ 17 | handleSaveApply: function(ev) { 18 | return this.handleSave(ev) 19 | .then(() => ui.changes.apply()) 20 | .then(() => uci.load('qosmate')) 21 | .then(() => uci.get_first('qosmate', 'global', 'enabled')) 22 | .then(enabled => { 23 | if (enabled === '0') { 24 | return fs.exec_direct('/etc/init.d/qosmate', ['stop']); 25 | } else { 26 | return fs.exec_direct('/etc/init.d/qosmate', ['restart']); 27 | } 28 | }) 29 | .then(() => { 30 | ui.hideModal(); 31 | window.location.reload(); 32 | }) 33 | .catch(err => { 34 | ui.hideModal(); 35 | ui.addNotification(null, E('p', _('Failed to save settings or update QoSmate service: ') + err.message)); 36 | }); 37 | }, 38 | 39 | render: function() { 40 | var m, s, o; 41 | 42 | m = new form.Map('qosmate', _('QoSmate HFSC Settings'), _('Configure HFSC settings for QoSmate.')); 43 | 44 | s = m.section(form.NamedSection, 'hfsc', 'hfsc', _('HFSC Settings')); 45 | s.anonymous = true; 46 | 47 | function createOption(name, title, description, placeholder, datatype) { 48 | var opt = s.option(form.Value, name, title, description); 49 | opt.datatype = datatype || 'string'; 50 | opt.rmempty = true; 51 | opt.placeholder = placeholder; 52 | 53 | if (datatype === 'uinteger') { 54 | opt.validate = function(section_id, value) { 55 | if (value === '' || value === null) return true; 56 | if (!/^\d+$/.test(value)) return _('Must be a non-negative integer or empty'); 57 | return true; 58 | }; 59 | } 60 | return opt; 61 | } 62 | 63 | o = s.option(form.ListValue, 'LINKTYPE', _('Link Type'), _('Select the link type')); 64 | o.value('ethernet', _('Ethernet')); 65 | o.value('atm', _('ATM')); 66 | o.value('adsl', _('ADSL')); 67 | o.default = 'ethernet'; 68 | 69 | createOption('OH', _('Overhead'), _('Set the overhead'), _('Default: 44'), 'uinteger'); 70 | 71 | o = s.option(form.ListValue, 'gameqdisc', _('Game Queue Discipline'), _('Queueing method for traffic classified as realtime')); 72 | o.value('pfifo', _('PFIFO')); 73 | o.value('fq_codel', _('FQ_CODEL')); 74 | o.value('bfifo', _('BFIFO')); 75 | o.value('red', _('RED')); 76 | o.value('netem', _('NETEM')); 77 | o.default = 'pfifo'; 78 | 79 | createOption('GAMEUP', _('Game Upload (kbps)'), _('Bandwidth reserved for realtime upload traffic'), _('Default: 15% of UPRATE + 400'), 'uinteger'); 80 | createOption('GAMEDOWN', _('Game Download (kbps)'), _('Bandwidth reserved for realtime download traffic'), _('Default: 15% of DOWNRATE + 400'), 'uinteger'); 81 | 82 | o = s.option(form.ListValue, 'nongameqdisc', _('Non-Game Queue Discipline'), _('Select the queueing discipline for non-realtime traffic')); 83 | o.value('fq_codel', _('FQ_CODEL')); 84 | o.value('cake', _('CAKE')); 85 | o.default = 'fq_codel'; 86 | 87 | createOption('nongameqdiscoptions', _('Non-Game QDisc Options'), _('Cake options for non-realtime queueing discipline'), _('Default: besteffort ack-filter')); 88 | createOption('MAXDEL', _('Max Delay (ms)'), _('Target max delay for realtime packets after burst (pfifo, bfifo, red)'), _('Default: 24'), 'uinteger'); 89 | createOption('PFIFOMIN', _('PFIFO Min'), _('Minimum packet count for PFIFO queue'), _('Default: 5'), 'uinteger'); 90 | createOption('PACKETSIZE', _('Avg Packet Size (B)'), _('Used with PFIFOMIN to calculate PFIFO limit'), _('Default: 450'), 'uinteger'); 91 | createOption('netemdelayms', _('NETEM Delay (ms)'), _('NETEM delay in milliseconds'), _('Default: 30'), 'uinteger'); 92 | createOption('netemjitterms', _('NETEM Jitter (ms)'), _('NETEM jitter in milliseconds'), _('Default: 7'), 'uinteger'); 93 | 94 | o = s.option(form.ListValue, 'netem_direction', _('NETEM Direction'), _('Select which direction to apply the NETEM delay/jitter settings')); 95 | o.depends('gameqdisc', 'netem'); 96 | o.value('both', _('Both Directions')); 97 | o.value('egress', _('Egress Only')); 98 | o.value('ingress', _('Ingress Only')); 99 | o.default = 'both'; 100 | 101 | o = s.option(form.ListValue, 'netemdist', _('NETEM Distribution'), _('NETEM delay distribution')); 102 | o.value('experimental', _('Experimental')); 103 | o.value('normal', _('Normal')); 104 | o.value('pareto', _('Pareto')); 105 | o.value('paretonormal', _('Pareto Normal')); 106 | o.default = 'normal'; 107 | 108 | createOption('pktlossp', _('Packet Loss Percentage'), _('Percentage of packet loss'), _('Default: none')); 109 | 110 | return m.render(); 111 | } 112 | }); 113 | -------------------------------------------------------------------------------- /htdocs/luci-static/resources/view/ipsets.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 'require view'; 3 | 'require rpc'; 4 | 'require ui'; 5 | 'require uci'; 6 | 'require form'; 7 | 'require fs'; 8 | 'require tools.widgets as widgets'; 9 | 10 | var callInitAction = rpc.declare({ 11 | object: 'luci', 12 | method: 'setInitAction', 13 | params: ['name', 'action'], 14 | expect: { result: false } 15 | }); 16 | 17 | return view.extend({ 18 | handleSaveApply: function(ev) { 19 | return this.handleSave(ev) 20 | .then(() => ui.changes.apply()) 21 | .then(() => uci.load('qosmate')) 22 | .then(() => uci.get_first('qosmate', 'global', 'enabled')) 23 | .then(enabled => { 24 | if (enabled === '0') { 25 | return fs.exec_direct('/etc/init.d/qosmate', ['stop']); 26 | } else { 27 | return fs.exec_direct('/etc/init.d/qosmate', ['restart']); 28 | } 29 | }) 30 | .then(() => { 31 | ui.hideModal(); 32 | window.location.reload(); 33 | }) 34 | .catch(err => { 35 | ui.hideModal(); 36 | ui.addNotification(null, E('p', _('Failed to save settings or update QoSmate service: ') + err.message)); 37 | }); 38 | }, 39 | 40 | render: function() { 41 | var m, s, o; 42 | 43 | m = new form.Map('qosmate', _('QoSmate IP Sets'), 44 | _('Define groups of IP addresses that can be referenced in QoS rules using @setname')); 45 | 46 | s = m.section(form.GridSection, 'ipset', _('IP Sets')); 47 | s.addremove = true; 48 | s.anonymous = true; 49 | s.sortable = true; 50 | 51 | o = s.option(form.Value, 'name', _('Set Name')); 52 | o.rmempty = false; 53 | o.validate = function(section_id, value) { 54 | if (!value) { 55 | return _('Set name is required'); 56 | } 57 | if (!/^[a-zA-Z0-9_]+$/.test(value)) { 58 | return _('Set name must contain only letters, numbers, and underscore'); 59 | } 60 | return true; 61 | }; 62 | 63 | o = s.option(form.ListValue, 'mode', _('Set Mode')); 64 | o.value('static', _('Static')); 65 | o.value('dynamic', _('Dynamic')); 66 | o.default = 'static'; 67 | o.rmempty = false; 68 | 69 | o = s.option(form.ListValue, 'family', _('Family')); 70 | o.value('ipv4', _('IPv4')); 71 | o.value('ipv6', _('IPv6')); 72 | o.default = 'ipv4'; 73 | o.rmempty = false; 74 | 75 | o = s.option(form.DynamicList, 'ip4', _('IPv4 Addresses')); 76 | o.datatype = 'ip4addr'; 77 | o.rmempty = true; 78 | o.placeholder = _('Add IPv4 address or subnet'); 79 | o.depends({ mode: 'static', family: 'ipv4' }); 80 | 81 | o = s.option(form.DynamicList, 'ip6', _('IPv6 Addresses')); 82 | o.datatype = 'ip6addr'; 83 | o.rmempty = true; 84 | o.placeholder = _('Add IPv6 address or subnet'); 85 | o.depends({ mode: 'static', family: 'ipv6' }); 86 | 87 | o = s.option(form.Value, 'timeout', _('Timeout')); 88 | o.placeholder = _('e.g., 1h'); 89 | o.depends('mode', 'dynamic'); 90 | o.validate = function(section_id, value) { 91 | if (!value) 92 | return true; // Allow empty value if applicable 93 | // Validate that the timeout is in a valid format (e.g., combination of numbers and allowed time units: h, m, s) 94 | if (!/^(\d+[hms])+$/.test(value)) { 95 | return _('Timeout must be in a valid format (e.g., "10s", "1h", "2h12m10s")'); 96 | } 97 | return true; 98 | }; 99 | 100 | o = s.option(form.Flag, 'enabled', _('Enabled')); 101 | o.default = '1'; 102 | o.rmempty = false; 103 | 104 | return m.render(); 105 | } 106 | }); 107 | -------------------------------------------------------------------------------- /htdocs/luci-static/resources/view/rules.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 'require view'; 3 | 'require ui'; 4 | 'require uci'; 5 | 'require form'; 6 | 'require rpc'; 7 | 'require fs'; 8 | 'require tools.widgets as widgets'; 9 | 10 | var callInitAction = rpc.declare({ 11 | object: 'luci', 12 | method: 'setInitAction', 13 | params: ['name', 'action'], 14 | expect: { result: false } 15 | }); 16 | 17 | return view.extend({ 18 | handleSaveApply: function(ev) { 19 | return this.handleSave(ev) 20 | .then(() => ui.changes.apply()) 21 | .then(() => uci.load('qosmate')) 22 | .then(() => uci.get_first('qosmate', 'global', 'enabled')) 23 | .then(enabled => { 24 | if (enabled === '0') { 25 | return fs.exec_direct('/etc/init.d/qosmate', ['stop']); 26 | } else { 27 | return fs.exec_direct('/etc/init.d/qosmate', ['restart']); 28 | } 29 | }) 30 | .then(() => { 31 | ui.hideModal(); 32 | window.location.reload(); 33 | }) 34 | .catch(err => { 35 | ui.hideModal(); 36 | ui.addNotification(null, E('p', _('Failed to save settings or update QoSmate service: ') + err.message)); 37 | }); 38 | }, 39 | 40 | render: function() { 41 | var m, s, o; 42 | 43 | m = new form.Map('qosmate', _('QoSmate Rules'), 44 | _('Configure QoS rules for marking packets with DSCP values.')); 45 | 46 | s = m.section(form.GridSection, 'rule', _('Rules')); 47 | s.addremove = true; 48 | s.anonymous = true; 49 | s.sortable = true; 50 | 51 | s.tab('general', _('General Settings')); 52 | s.tab('mapping', _('DSCP Mapping')); 53 | 54 | // Add mapping information to the description 55 | s.description = E('div', { 'class': 'cbi-section-descr' }, [ 56 | E('h4', _('HFSC Mapping:')), 57 | E('table', { 'class': 'table' }, [ 58 | E('tr', { 'class': 'tr' }, [ 59 | E('td', { 'class': 'td left', 'width': '50%' }, _('High Priority [Realtime] (1:11)')), 60 | E('td', { 'class': 'td left' }, 'EF, CS5, CS6, CS7') 61 | ]), 62 | E('tr', { 'class': 'tr' }, [ 63 | E('td', { 'class': 'td left' }, _('Fast Non-Realtime (1:12)')), 64 | E('td', { 'class': 'td left' }, 'CS4, AF41, AF42') 65 | ]), 66 | E('tr', { 'class': 'tr' }, [ 67 | E('td', { 'class': 'td left' }, _('Normal (1:13)')), 68 | E('td', { 'class': 'td left' }, 'CS0') 69 | ]), 70 | E('tr', { 'class': 'tr' }, [ 71 | E('td', { 'class': 'td left' }, _('Low Priority (1:14)')), 72 | E('td', { 'class': 'td left' }, 'CS2, AF11') 73 | ]), 74 | E('tr', { 'class': 'tr' }, [ 75 | E('td', { 'class': 'td left' }, _('Bulk (1:15)')), 76 | E('td', { 'class': 'td left' }, 'CS1') 77 | ]) 78 | ]), 79 | E('h4', _('CAKE Mapping (diffserv4):')), 80 | E('table', { 'class': 'table' }, [ 81 | E('tr', { 'class': 'tr' }, [ 82 | E('td', { 'class': 'td left', 'width': '50%' }, _('Voice (Highest Priority)')), 83 | E('td', { 'class': 'td left' }, 'CS7, CS6, EF, VA, CS5, CS4') 84 | ]), 85 | E('tr', { 'class': 'tr' }, [ 86 | E('td', { 'class': 'td left' }, _('Video')), 87 | E('td', { 'class': 'td left' }, 'CS3, AF4x, AF3x, AF2x, CS2, TOS1') 88 | ]), 89 | E('tr', { 'class': 'tr' }, [ 90 | E('td', { 'class': 'td left' }, _('Best Effort')), 91 | E('td', { 'class': 'td left' }, 'CS0, AF1x, TOS0') 92 | ]), 93 | E('tr', { 'class': 'tr' }, [ 94 | E('td', { 'class': 'td left' }, _('Bulk (Lowest Priority)')), 95 | E('td', { 'class': 'td left' }, 'CS1, LE') 96 | ]) 97 | ]) 98 | ]); 99 | 100 | o = s.taboption('general', form.Value, 'name', _('Name')); 101 | o.rmempty = false; 102 | 103 | o = s.option(form.DummyValue, 'proto', _('Protocol')); 104 | o.cfgvalue = function(section_id) { 105 | var proto = uci.get('qosmate', section_id, 'proto'); 106 | if (Array.isArray(proto)) { 107 | return proto.map(function(p) { return p.toUpperCase(); }).join(', '); 108 | } else if (typeof proto === 'string') { 109 | return proto.toUpperCase(); 110 | } 111 | return _('Any'); 112 | }; 113 | 114 | o = s.taboption('general', form.MultiValue, 'proto', _('Protocol')); 115 | o.value('tcp', _('TCP')); 116 | o.value('udp', _('UDP')); 117 | o.value('icmp', _('ICMP')); 118 | o.rmempty = true; 119 | o.default = 'tcp udp'; 120 | o.modalonly = true; 121 | 122 | o.cfgvalue = function(section_id) { 123 | var value = uci.get('qosmate', section_id, 'proto'); 124 | if (Array.isArray(value)) { 125 | return value; 126 | } else if (typeof value === 'string') { 127 | return value.split(/\s+/); 128 | } 129 | return []; 130 | }; 131 | 132 | o.write = function(section_id, value) { 133 | if (value && value.length) { 134 | uci.set('qosmate', section_id, 'proto', value.join(' ')); 135 | } else { 136 | uci.unset('qosmate', section_id, 'proto'); 137 | } 138 | }; 139 | 140 | o.validate = function(section_id, value) { 141 | if (!value || value.length === 0) { 142 | return true; 143 | } 144 | 145 | var valid = ['tcp', 'udp', 'icmp']; 146 | var toValidate = Array.isArray(value) ? value : value.split(/\s+/); 147 | 148 | for (var i = 0; i < toValidate.length; i++) { 149 | if (valid.indexOf(toValidate[i]) === -1) { 150 | return _('Invalid protocol: %s').format(toValidate[i]); 151 | } 152 | } 153 | return true; 154 | }; 155 | 156 | o.remove = function(section_id) { 157 | uci.unset('qosmate', section_id, 'proto'); 158 | }; 159 | 160 | o = s.taboption('general', form.DynamicList, 'src_ip', _('Source IP')); 161 | o.datatype = 'string'; 162 | o.placeholder = _('IP address or @setname'); 163 | o.rmempty = true; 164 | o.validate = function(section_id, value) { 165 | if (!value || value.length === 0) { 166 | return true; 167 | } 168 | 169 | var values = Array.isArray(value) ? value : value.split(/\s+/); 170 | var ipCidrRegex = /^(?:(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)(?:\.(?:25[0-5]|2[0-4]\d|[01]?\d\d?)){3})(?:\/(?:[0-9]|[1-2]\d|3[0-2]))?|(?:(?:[A-Fa-f0-9]{1,4}:){7}[A-Fa-f0-9]{1,4}|(?:[A-Fa-f0-9]{1,4}:){1,7}:|(?:[A-Fa-f0-9]{1,4}:){1,6}:[A-Fa-f0-9]{1,4}|(?:[A-Fa-f0-9]{1,4}:){1,5}(?::[A-Fa-f0-9]{1,4}){1,2}|(?:[A-Fa-f0-9]{1,4}:){1,4}(?::[A-Fa-f0-9]{1,4}){1,3}|(?:[A-Fa-f0-9]{1,4}:){1,3}(?::[A-Fa-f0-9]{1,4}){1,4}|(?:[A-Fa-f0-9]{1,4}:){1,2}(?::[A-Fa-f0-9]{1,4}){1,5}|[A-Fa-f0-9]{1,4}:(?:(?::[A-Fa-f0-9]{1,4}){1,6})|:(?:(?::[A-Fa-f0-9]{1,4}){1,7}|:))(?:\/(?:[0-9]|[1-9]\d|1[0-1]\d|12[0-8]))?)$/; 171 | 172 | for (var i = 0; i < values.length; i++) { 173 | var v = values[i].replace(/^!(?!=)/, '!='); 174 | if (v.startsWith('@')) { 175 | if (!/^@[a-zA-Z0-9_]+$/.test(v)) { 176 | return _('Invalid set name format. Must start with @ followed by letters, numbers, or underscore'); 177 | } 178 | } else { 179 | if (!ipCidrRegex.test(v)) { 180 | return _('Invalid IP address or CIDR format: ') + v; 181 | } 182 | } 183 | } 184 | return true; 185 | }; 186 | o.write = function(section_id, formvalue) { 187 | var values = formvalue.map(function(v) { 188 | return v.replace(/^!(?!=)/, '!='); 189 | }); 190 | return this.super('write', [section_id, values]); 191 | }; 192 | 193 | o = s.taboption('general', form.DynamicList, 'src_port', _('Source port')); 194 | o.datatype = 'list(neg(portrange))'; 195 | o.placeholder = _('any'); 196 | o.rmempty = true; 197 | o.write = function(section_id, formvalue) { 198 | var values = formvalue.map(function(v) { 199 | return v.replace(/^!(?!=)/, '!='); 200 | }); 201 | return this.super('write', [section_id, values]); 202 | }; 203 | 204 | o = s.taboption('general', form.DynamicList, 'dest_ip', _('Destination IP')); 205 | o.datatype = 'string'; 206 | o.placeholder = _('IP address or @setname'); 207 | o.rmempty = true; 208 | o.validate = function(section_id, value) { 209 | if (!value || value.length === 0) { 210 | return true; 211 | } 212 | 213 | var values = Array.isArray(value) ? value : value.split(/\s+/); 214 | var ipCidrRegex = /^(?:(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)(?:\.(?:25[0-5]|2[0-4]\d|[01]?\d\d?)){3})(?:\/(?:[0-9]|[1-2]\d|3[0-2]))?|(?:(?:[A-Fa-f0-9]{1,4}:){7}[A-Fa-f0-9]{1,4}|(?:[A-Fa-f0-9]{1,4}:){1,7}:|(?:[A-Fa-f0-9]{1,4}:){1,6}:[A-Fa-f0-9]{1,4}|(?:[A-Fa-f0-9]{1,4}:){1,5}(?::[A-Fa-f0-9]{1,4}){1,2}|(?:[A-Fa-f0-9]{1,4}:){1,4}(?::[A-Fa-f0-9]{1,4}){1,3}|(?:[A-Fa-f0-9]{1,4}:){1,3}(?::[A-Fa-f0-9]{1,4}){1,4}|(?:[A-Fa-f0-9]{1,4}:){1,2}(?::[A-Fa-f0-9]{1,4}){1,5}|[A-Fa-f0-9]{1,4}:(?:(?::[A-Fa-f0-9]{1,4}){1,6})|:(?:(?::[A-Fa-f0-9]{1,4}){1,7}|:))(?:\/(?:[0-9]|[1-9]\d|1[0-1]\d|12[0-8]))?)$/; 215 | 216 | for (var i = 0; i < values.length; i++) { 217 | var v = values[i].replace(/^!(?!=)/, '!='); 218 | if (v.startsWith('@')) { 219 | if (!/^@[a-zA-Z0-9_]+$/.test(v)) { 220 | return _('Invalid set name format. Must start with @ followed by letters, numbers, or underscore'); 221 | } 222 | } else { 223 | if (!ipCidrRegex.test(v)) { 224 | return _('Invalid IP address or CIDR format: ') + v; 225 | } 226 | } 227 | } 228 | return true; 229 | }; 230 | o.write = function(section_id, formvalue) { 231 | var values = formvalue.map(function(v) { 232 | return v.replace(/^!(?!=)/, '!='); 233 | }); 234 | return this.super('write', [section_id, values]); 235 | }; 236 | 237 | o = s.taboption('general', form.DynamicList, 'dest_port', _('Destination port')); 238 | o.datatype = 'list(neg(portrange))'; 239 | o.placeholder = _('any'); 240 | o.rmempty = true; 241 | o.write = function(section_id, formvalue) { 242 | var values = formvalue.map(function(v) { 243 | return v.replace(/^!(?!=)/, '!='); 244 | }); 245 | return this.super('write', [section_id, values]); 246 | }; 247 | 248 | o = s.taboption('general', form.ListValue, 'class', _('DSCP Class')); 249 | o.value('ef', _('EF - Expedited Forwarding (46)')); 250 | o.value('cs5', _('CS5 (40)')); 251 | o.value('cs6', _('CS6 (48)')); 252 | o.value('cs7', _('CS7 (56)')); 253 | o.value('cs4', _('CS4 (32)')); 254 | o.value('af41', _('AF41 (34)')); 255 | o.value('af42', _('AF42 (36)')); 256 | o.value('af11', _('AF11 (10)')); 257 | o.value('cs2', _('CS2 (16)')); 258 | o.value('cs1', _('CS1 (8)')); 259 | o.value('cs0', _('CS0 - Best Effort (0)')); 260 | o.rmempty = false; 261 | 262 | o = s.taboption('general', form.Flag, 'counter', _('Enable counter')); 263 | o.rmempty = false; 264 | 265 | o = s.taboption('general', form.Flag, 'trace', _('Enable trace')); 266 | o.rmempty = false; 267 | o.default = '0'; // Default to disabled 268 | o.description = _('Debug only'); 269 | 270 | o = s.taboption('general', form.Flag, 'enabled', _('Enable')); 271 | o.rmempty = false; 272 | o.editable = true; 273 | o.default = '1'; // Set default value to enabled 274 | o.write = function(section_id, formvalue) { 275 | // Always write the value, whether it's '0' or '1' 276 | uci.set('qosmate', section_id, 'enabled', formvalue); 277 | }; 278 | o.load = function(section_id) { 279 | var value = uci.get('qosmate', section_id, 'enabled'); 280 | // If the value is undefined (not set in config), return '1' (enabled) 281 | return (value === undefined) ? '1' : value; 282 | }; 283 | 284 | return m.render(); 285 | } 286 | }); 287 | -------------------------------------------------------------------------------- /htdocs/luci-static/resources/view/settings.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 'require view'; 3 | 'require form'; 4 | 'require ui'; 5 | 'require uci'; 6 | 'require rpc'; 7 | 'require fs'; 8 | 'require poll'; 9 | 'require tools.widgets as widgets'; 10 | 11 | const UI_VERSION = '1.2.0'; 12 | const UI_UPD_CHANNEL = 'release'; 13 | 14 | var callInitAction = rpc.declare({ 15 | object: 'luci', 16 | method: 'setInitAction', 17 | params: ['name', 'action'], 18 | expect: { result: false } 19 | }); 20 | 21 | function createStatusText(status, text) { 22 | var colors = { 23 | 'current': '#4CAF50', // Green 24 | 'update': '#FF5252', // Red 25 | 'error': '#FFC107', // Yellow 26 | 'unknown': '#9E9E9E' // Gray 27 | }; 28 | 29 | var icons = { 30 | 'current': '✓ ', 31 | 'update': '↑ ', 32 | 'error': '⚠ ', 33 | 'unknown': '? ' 34 | }; 35 | 36 | return E('span', { 37 | 'style': 'color: ' + colors[status] + '; font-weight: bold; font-size: 13px;' 38 | }, icons[status] + text); 39 | } 40 | 41 | var healthCheckData = null; 42 | var versionInfo = { 43 | backend: { current: 'Unknown', latest: 'Unknown', channel: 'Unknown' }, 44 | frontend: { current: 'Unknown', latest: 'Unknown', channel: 'Unknown' } 45 | }; 46 | 47 | function fetchVersionInfo() { 48 | return fs.exec_direct('/etc/init.d/qosmate', ['check_version']) 49 | .then(function(output) { 50 | // Check for API limit error 51 | if (output.includes('HTTP error 403') || output.includes('API rate limit exceeded')) { 52 | console.warn('GitHub API rate limit likely reached.'); 53 | 54 | // Try to parse current versions even if latest check failed due to rate limit 55 | const backendCurrentMatch = output.match(/Backend versions:[\s\S]*?Current version: (.+)/); 56 | const backendChannelMatch = output.match(/Backend versions:[\s\S]*?Update channel: (.+)/); 57 | const frontendCurrentMatch = output.match(/Frontend versions:[\s\S]*?Current version: (.+)/); 58 | const frontendChannelMatch = output.match(/Frontend versions:[\s\S]*?Update channel: (.+)/); 59 | 60 | versionInfo = { 61 | backend: { 62 | current: backendCurrentMatch ? backendCurrentMatch[1].trim() : 'Unknown', 63 | latest: 'API limit reached', 64 | channel: backendChannelMatch ? backendChannelMatch[1].trim() : 'Unknown' 65 | }, 66 | frontend: { 67 | current: frontendCurrentMatch ? frontendCurrentMatch[1].trim() : 'Unknown', 68 | latest: 'API limit reached', 69 | channel: frontendChannelMatch ? frontendChannelMatch[1].trim() : 'Unknown' 70 | } 71 | }; 72 | 73 | } else { 74 | // Normal processing 75 | const backendCurrentMatch = output.match(/Backend versions:[\s\S]*?Current version: (.+)/); 76 | const backendLatestMatch = output.match(/Backend versions:[\s\S]*?Latest version: (.+)/); 77 | const backendChannelMatch = output.match(/Backend versions:[\s\S]*?Update channel: (.+)/); 78 | 79 | const frontendCurrentMatch = output.match(/Frontend versions:[\s\S]*?Current version: (.+)/); 80 | const frontendLatestMatch = output.match(/Frontend versions:[\s\S]*?Latest version: (.+)/); 81 | const frontendChannelMatch = output.match(/Frontend versions:[\s\S]*?Update channel: (.+)/); 82 | 83 | versionInfo = { 84 | backend: { 85 | current: backendCurrentMatch ? backendCurrentMatch[1].trim() : 'Unknown', 86 | latest: backendLatestMatch ? backendLatestMatch[1].trim() : 'Unknown', 87 | channel: backendChannelMatch ? backendChannelMatch[1].trim() : 'Unknown' 88 | }, 89 | frontend: { 90 | current: frontendCurrentMatch ? frontendCurrentMatch[1].trim() : 'Unknown', 91 | latest: frontendLatestMatch ? frontendLatestMatch[1].trim() : 'Unknown', 92 | channel: frontendChannelMatch ? frontendChannelMatch[1].trim() : 'Unknown' 93 | } 94 | }; 95 | } 96 | 97 | return versionInfo; 98 | }) 99 | .catch(function(error) { 100 | console.error('Error fetching version information:', error); 101 | // Keep previous info if available, otherwise set to error state 102 | if (versionInfo.backend.current === 'Unknown' && versionInfo.frontend.current === 'Unknown') { 103 | versionInfo = { 104 | backend: { current: 'Unknown', latest: 'Error', channel: 'Unknown' }, 105 | frontend: { current: 'Unknown', latest: 'Error', channel: 'Unknown' } 106 | }; 107 | } else { 108 | versionInfo.backend.latest = 'Error'; 109 | versionInfo.frontend.latest = 'Error'; 110 | } 111 | 112 | return versionInfo; 113 | }); 114 | } 115 | 116 | return view.extend({ 117 | handleSaveApply: function(ev) { 118 | return this.handleSave(ev) 119 | .then(() => ui.changes.apply()) 120 | .then(() => uci.load('qosmate')) 121 | .then(() => uci.get_first('qosmate', 'global', 'enabled')) 122 | .then(enabled => { 123 | if (enabled === '0') { 124 | return fs.exec_direct('/etc/init.d/qosmate', ['stop']); 125 | } else { 126 | return fs.exec_direct('/etc/init.d/qosmate', ['restart']); 127 | } 128 | }) 129 | .then(() => { 130 | ui.hideModal(); 131 | window.location.reload(); 132 | }) 133 | .catch(err => { 134 | ui.hideModal(); 135 | ui.addNotification(null, E('p', _('Failed to save settings or update QoSmate service: ') + err.message)); 136 | }); 137 | }, 138 | 139 | load: function() { 140 | return Promise.all([ 141 | uci.load('qosmate'), 142 | this.fetchHealthCheck(), 143 | fetchVersionInfo() 144 | ]).catch(error => { 145 | console.error('Error in load function:', error); 146 | ui.addNotification(null, E('p', _('Error loading initial data: %s').format(error.message || error)), 'error'); 147 | return [null, null, null]; 148 | }); 149 | }, 150 | 151 | fetchHealthCheck: function() { 152 | return fs.exec_direct('/etc/init.d/qosmate', ['health_check']) 153 | .then((res) => { 154 | var output = res.trim(); 155 | // Parse the full status string (everything between status= and ;errors=) 156 | var statusMatch = output.match(/status=(.*?);errors=/); 157 | var errorsMatch = output.match(/errors=(\d+)$/); 158 | 159 | var statusString = statusMatch ? statusMatch[1] : 'Unknown'; 160 | var errorsCount = errorsMatch ? parseInt(errorsMatch[1]) : 0; 161 | 162 | var statusSegments = statusString.split(';'); 163 | var detailsArray = []; 164 | statusSegments.forEach(function(segment) { 165 | if (!segment) return; 166 | detailsArray.push(segment); 167 | }); 168 | 169 | healthCheckData = { 170 | details: detailsArray, 171 | errors: errorsCount 172 | }; 173 | // console.log("Health check data loaded successfully:", healthCheckData); 174 | }) 175 | .catch((err) => { 176 | console.error('Health check failed:', err); 177 | healthCheckData = { 178 | details: ['Health check failed: ' + err], 179 | errors: 1 180 | }; 181 | }); 182 | }, 183 | 184 | render: function() { 185 | var m, s_info, s_status, o; 186 | 187 | m = new form.Map('qosmate', _(''), _('')); 188 | 189 | s_info = m.section(form.NamedSection, 'global', 'global', _('Version & Updates')); 190 | s_info.anonymous = true; 191 | 192 | // Version information 193 | o = s_info.option(form.DummyValue, '_version', _('Version Information')); 194 | o.rawhtml = true; 195 | o.render = function(section_id) { 196 | // Determine if an update is available for backend 197 | var backendUpdateAvailable = versionInfo.backend.current !== versionInfo.backend.latest && 198 | versionInfo.backend.current !== 'Unknown' && 199 | versionInfo.backend.latest !== 'Unknown' && 200 | versionInfo.backend.latest !== 'API limit reached' && 201 | versionInfo.backend.latest !== 'Error'; 202 | 203 | // Determine if an update is available for frontend 204 | var frontendUpdateAvailable = versionInfo.frontend.current !== versionInfo.frontend.latest && 205 | versionInfo.frontend.current !== 'Unknown' && 206 | versionInfo.frontend.latest !== 'Unknown' && 207 | versionInfo.frontend.latest !== 'API limit reached' && 208 | versionInfo.frontend.latest !== 'Error'; 209 | 210 | var container = E('div'); 211 | 212 | // Create each component section 213 | function createComponentSection(title, info) { 214 | var section = E('div', { 'style': 'display: flex; align-items: center; margin-bottom: 8px;' }); 215 | var titleEl = E('div', { 216 | 'style': 'display: inline-block; min-width: 75px; font-weight: bold; margin-right: 1px;' 217 | }, title); 218 | 219 | section.appendChild(titleEl); 220 | 221 | var channelEl = E('div', { 222 | 'style': 'display: inline-block; min-width: 70px; color: #888; margin-right: 15px;' 223 | }, [ 224 | E('span', { 'style': 'font-family: monospace;' }, 'Channel: ' + info.channel) 225 | ]); 226 | 227 | section.appendChild(channelEl); 228 | 229 | var versionInfo = E('div', { 'style': 'display: inline-block; margin-right: 10px;' }, [ 230 | info.current, 231 | ' → ', 232 | E('span', { 233 | 'style': (title === 'Backend' && backendUpdateAvailable) || 234 | (title === 'Frontend' && frontendUpdateAvailable) ? 235 | 'color: #ff7d7d; font-weight: bold;' : '' 236 | }, info.latest) 237 | ]); 238 | 239 | section.appendChild(versionInfo); 240 | 241 | var statusType = ''; 242 | var statusText = ''; 243 | 244 | if ((title === 'Backend' && backendUpdateAvailable) || 245 | (title === 'Frontend' && frontendUpdateAvailable)) { 246 | statusType = 'update'; 247 | statusText = _('UPDATE AVAILABLE'); 248 | } else if (info.latest === 'API limit reached') { 249 | statusType = 'error'; 250 | statusText = _('API LIMIT'); 251 | } else if (info.latest === 'Error') { 252 | statusType = 'error'; 253 | statusText = _('ERROR'); 254 | } else if (info.current !== 'Unknown' && info.latest !== 'Unknown') { 255 | statusType = 'current'; 256 | statusText = _('CURRENT'); 257 | } else { 258 | statusType = 'unknown'; 259 | statusText = _('UNKNOWN'); 260 | } 261 | 262 | section.appendChild(createStatusText(statusType, statusText)); 263 | 264 | return section; 265 | } 266 | 267 | // Create component sections 268 | container.appendChild(createComponentSection('Backend', versionInfo.backend)); 269 | container.appendChild(createComponentSection('Frontend', versionInfo.frontend)); 270 | 271 | // Add the update button if updates are available 272 | if (backendUpdateAvailable || frontendUpdateAvailable) { 273 | var buttonContainer = E('div', { 'style': 'margin-top: 10px;' }); 274 | 275 | var updateButton = E('button', { 276 | 'class': 'cbi-button cbi-button-apply', 277 | 'click': ui.createHandlerFn(this, function() { 278 | // Create update wizard modal 279 | var updateOptions = []; 280 | 281 | if (backendUpdateAvailable) { 282 | updateOptions.push({ 283 | name: 'backend', 284 | title: _('Backend'), 285 | current: versionInfo.backend.current, 286 | latest: versionInfo.backend.latest 287 | }); 288 | } 289 | 290 | if (frontendUpdateAvailable) { 291 | updateOptions.push({ 292 | name: 'frontend', 293 | title: _('Frontend'), 294 | current: versionInfo.frontend.current, 295 | latest: versionInfo.frontend.latest 296 | }); 297 | } 298 | 299 | var modalContent = [ 300 | E('h4', {}, _('Update QoSmate Components')), 301 | E('p', {}, _('Select components to update:')) 302 | ]; 303 | 304 | var checkboxes = {}; 305 | updateOptions.forEach(function(option) { 306 | var checkbox = E('input', { 307 | 'type': 'checkbox', 308 | 'id': 'update_' + option.name, 309 | 'name': 'update_' + option.name, 310 | 'checked': 'checked' 311 | }); 312 | 313 | checkboxes[option.name] = checkbox; 314 | 315 | modalContent.push( 316 | E('div', { 'class': 'cbi-value' }, [ 317 | E('label', { 'class': 'cbi-value-title', 'for': 'update_' + option.name }, option.title), 318 | E('div', { 'class': 'cbi-value-field' }, [ 319 | checkbox, 320 | ' ', 321 | option.current, 322 | ' → ', 323 | E('span', { 'style': 'color: #ff7d7d; font-weight: bold;' }, option.latest) 324 | ]) 325 | ]) 326 | ); 327 | }); 328 | 329 | // Update channel info 330 | modalContent.push( 331 | E('div', { 'class': 'cbi-value' }, [ 332 | E('label', { 'class': 'cbi-value-title' }, _('Update Channel')), 333 | E('div', { 'class': 'cbi-value-field' }, [ 334 | E('span', {}, versionInfo.backend.channel === versionInfo.frontend.channel ? 335 | versionInfo.backend.channel : 336 | _('%s (Backend) / %s (Frontend)').format(versionInfo.backend.channel, versionInfo.frontend.channel)), 337 | E('div', { 'style': 'font-size: 90%; color: #888; margin-top: 5px;' }, 338 | _('To change the update channel, go to the Advanced tab')) 339 | ]) 340 | ]) 341 | ); 342 | 343 | // Add buttons 344 | modalContent.push( 345 | E('div', { 'class': 'right' }, [ 346 | E('button', { 347 | 'class': 'btn', 348 | 'click': ui.hideModal 349 | }, _('Cancel')), 350 | ' ', 351 | E('button', { 352 | 'class': 'cbi-button cbi-button-positive', 353 | 'click': ui.createHandlerFn(this, function() { 354 | var componentsToUpdate = []; 355 | 356 | updateOptions.forEach(function(option) { 357 | if (checkboxes[option.name].checked) { 358 | componentsToUpdate.push(option.name); 359 | } 360 | }); 361 | 362 | if (componentsToUpdate.length === 0) { 363 | ui.hideModal(); 364 | return; 365 | } 366 | 367 | ui.showModal(_('Updating QoSmate'), [ 368 | E('p', { 'class': 'spinning' }, _('Please wait while QoSmate is being updated...')) 369 | ]); 370 | 371 | // Use the current channel from versionInfo 372 | var selectedChannel; 373 | if (versionInfo.backend.channel === versionInfo.frontend.channel) { 374 | selectedChannel = versionInfo.backend.channel; 375 | } else { 376 | // If channels are mixed, show a confirmation dialog 377 | if (!confirm(_('Components are using different update channels (%s/%s). Continue with %s channel?') 378 | .format(versionInfo.backend.channel, versionInfo.frontend.channel, versionInfo.backend.channel))) { 379 | ui.hideModal(); 380 | return; 381 | } 382 | selectedChannel = versionInfo.backend.channel; 383 | } 384 | 385 | var updateArgs = ['update']; 386 | 387 | // Add component selection if not updating both components 388 | if (componentsToUpdate.length === 1) { 389 | updateArgs.push('-c', componentsToUpdate[0]); 390 | } 391 | 392 | // Add channel selection 393 | updateArgs.push('-v', selectedChannel); 394 | 395 | console.log('Executing update command:', '/etc/init.d/qosmate', updateArgs); 396 | 397 | return fs.exec_direct('/etc/init.d/qosmate', updateArgs) 398 | .then(function(result) { 399 | console.log('Update command result:', result); 400 | // If result contains error messages, treat it as an error 401 | if (result && (result.includes('error') || result.includes('Error') || result.includes('failed'))) { 402 | ui.hideModal(); 403 | ui.addNotification(null, E('p', _('Update process encountered issues: %s').format(result)), 'warning'); 404 | return; 405 | } 406 | 407 | // Simulate update completion after 5 seconds 408 | setTimeout(function() { 409 | ui.hideModal(); 410 | ui.addNotification(null, E('p', _('QoSmate updated successfully.')), 'success'); 411 | window.setTimeout(function() { 412 | location.reload(); 413 | }, 1000); 414 | }, 5000); 415 | }) 416 | .catch(function(err) { 417 | console.error('Update error:', err); 418 | ui.hideModal(); 419 | 420 | var errorMessage = _('Failed to update QoSmate'); 421 | 422 | if (err) { 423 | if (typeof err === 'string') { 424 | errorMessage += ': ' + err; 425 | } else if (err.message) { 426 | errorMessage += ': ' + err.message; 427 | } else { 428 | errorMessage += ': ' + JSON.stringify(err); 429 | } 430 | } 431 | 432 | if (selectedChannel === 'snapshot') { 433 | errorMessage += '. ' + _('Note: The "snapshot" channel might not be available in the current repository configuration.'); 434 | } 435 | 436 | ui.addNotification(null, E('p', errorMessage), 'error'); 437 | }); 438 | }) 439 | }, _('Update Now')) 440 | ]) 441 | ); 442 | 443 | ui.showModal(_('QoSmate Update'), modalContent); 444 | }) 445 | }, [ 446 | E('span', { 'class': 'cbi-button-icon cbi-icon-reload' }), 447 | ' ', 448 | _('Update QoSmate') 449 | ]); 450 | 451 | buttonContainer.appendChild(updateButton); 452 | container.appendChild(buttonContainer); 453 | } 454 | 455 | return E('div', { 'class': 'cbi-value' }, [ 456 | E('label', { 'class': 'cbi-value-title' }, _('Version Information')), 457 | E('div', { 'class': 'cbi-value-field' }, [ 458 | container 459 | ]) 460 | ]); 461 | }; 462 | 463 | // Section, also targeting 'global' but with a UI title for grouping 464 | s_status = m.section(form.NamedSection, 'global', 'global', _('Service Status & Control')); 465 | 466 | // Service Status (Health Check) 467 | o = s_status.option(form.DummyValue, '_health_check', _('')); 468 | o.rawhtml = true; 469 | o.render = function(section_id) { 470 | if (!healthCheckData) { 471 | return E('div', { 'class': 'cbi-value' }, [ 472 | E('label', { 'class': 'cbi-value-title' }, _('Service Status')), 473 | E('div', { 'class': 'cbi-value-field' }, _('Loading health check status...')) 474 | ]); 475 | } 476 | 477 | var statusHtml = E('div', { 'class': 'health-status', 'style': 'display: flex; gap: 16px; align-items: center;' }); 478 | 479 | healthCheckData.details.forEach(function(detail) { 480 | var [type, status] = detail.split(':'); 481 | var displayType = type.charAt(0).toUpperCase() + type.slice(1); 482 | var icon, color; 483 | switch(status.toLowerCase()) { 484 | case 'enabled': 485 | case 'started': 486 | icon = '✓'; 487 | color = 'green'; 488 | break; 489 | case 'disabled': 490 | case 'stopped': 491 | icon = '✕'; 492 | color = 'red'; 493 | break; 494 | case 'ok': 495 | icon = '✓'; 496 | color = 'green'; 497 | break; 498 | case 'failed': 499 | icon = '✕'; 500 | color = 'red'; 501 | break; 502 | case 'missing': 503 | icon = '⚠'; 504 | color = 'orange'; 505 | break; 506 | default: 507 | icon = '⚠'; 508 | color = 'orange'; 509 | } 510 | 511 | statusHtml.appendChild( 512 | E('div', { 'style': 'display: flex; align-items: center; gap: 4px;' }, [ 513 | E('span', { 514 | 'style': 'color: ' + color + '; font-size: 15px; font-weight: bold; min-width: 20px;' 515 | }, icon), 516 | E('span', { 517 | 'style': 'font-size: 13px; color: #666;' 518 | }, _(displayType)), 519 | ]) 520 | ); 521 | }); 522 | 523 | return E('div', { 'class': 'cbi-value' }, [ 524 | E('label', { 'class': 'cbi-value-title' }, _('Service Status')), 525 | E('div', { 'class': 'cbi-value-field' }, statusHtml) 526 | ]); 527 | }; 528 | 529 | // Service Control buttons 530 | o = s_status.option(form.DummyValue, '_buttons', _('')); 531 | o.rawhtml = true; 532 | o.render = function(section_id) { 533 | var buttonStyle = 'button cbi-button'; 534 | return E('div', { 'class': 'cbi-value' }, [ 535 | E('label', { 'class': 'cbi-value-title' }, _('Service Control')), 536 | E('div', { 'class': 'cbi-value-field' }, [ 537 | E('button', { 538 | 'class': buttonStyle + ' cbi-button-apply', 539 | 'click': ui.createHandlerFn(this, function() { 540 | return fs.exec_direct('/etc/init.d/qosmate', ['start']) 541 | .then(function() { 542 | ui.addNotification(null, E('p', _('QoSmate started')), 'success'); 543 | window.setTimeout(function() { location.reload(); }, 1000); 544 | }) 545 | .catch(function(e) { ui.addNotification(null, E('p', _('Failed to start QoSmate: ') + e), 'error'); }); 546 | }) 547 | }, _('Start')), 548 | ' ', 549 | E('button', { 550 | 'class': buttonStyle + ' cbi-button-neutral', 551 | 'click': ui.createHandlerFn(this, function() { 552 | return fs.exec_direct('/etc/init.d/qosmate', ['restart']) 553 | .then(function() { 554 | ui.addNotification(null, E('p', _('QoSmate restarted')), 'success'); 555 | window.setTimeout(function() { location.reload(); }, 1000); 556 | }) 557 | .catch(function(e) { ui.addNotification(null, E('p', _('Failed to restart QoSmate: ') + e), 'error'); }); 558 | }) 559 | }, _('Restart')), 560 | ' ', 561 | E('button', { 562 | 'class': buttonStyle + ' cbi-button-reset', 563 | 'click': ui.createHandlerFn(this, function() { 564 | return fs.exec_direct('/etc/init.d/qosmate', ['stop']) 565 | .then(function() { 566 | ui.addNotification(null, E('p', _('QoSmate stopped')), 'success'); 567 | window.setTimeout(function() { location.reload(); }, 1000); 568 | }) 569 | .catch(function(e) { ui.addNotification(null, E('p', _('Failed to stop QoSmate: ') + e), 'error'); }); 570 | }) 571 | }, _('Stop')) 572 | ]) 573 | ]); 574 | }; 575 | 576 | // Auto Setup Button 577 | o = s_status.option(form.Button, '_auto_setup', _('Auto Setup')); 578 | o.inputstyle = 'apply'; 579 | o.inputtitle = _('Start Auto Setup'); 580 | o.onclick = ui.createHandlerFn(this, function() { 581 | ui.showModal(_('Auto Setup'), [ 582 | E('p', _('This will run a speed test and configure QoSmate automatically.')), 583 | E('div', { 'class': 'cbi-value' }, [ 584 | E('label', { 'class': 'cbi-value-title' }, _('Gaming Device IP (optional)')), 585 | E('input', { 'id': 'gaming_ip', 'type': 'text', 'class': 'cbi-input-text' }) 586 | ]), 587 | E('div', { 'class': 'right' }, [ 588 | E('button', { 589 | 'class': 'btn', 590 | 'click': ui.hideModal 591 | }, _('Cancel')), 592 | ' ', 593 | E('button', { 594 | 'class': 'btn cbi-button-action', 595 | 'click': ui.createHandlerFn(this, function() { 596 | var gamingIp = document.getElementById('gaming_ip').value; 597 | ui.showModal(_('Running Auto Setup'), [ 598 | E('p', { 'class': 'spinning' }, _('Please wait while the auto setup is in progress...')), 599 | E('div', { 'style': 'margin-top: 1em; border-top: 1px solid #ccc; padding-top: 1em;' }, [ 600 | E('p', { 'style': 'font-weight: bold;' }, _('Note:')), 601 | E('p', _('Router-based speed tests may underestimate actual speeds. These results serve as a starting point and may require manual adjustment for optimal performance.')) 602 | ]) 603 | ]); 604 | return fs.exec_direct('/etc/init.d/qosmate', ['auto_setup_noninteractive', gamingIp]) 605 | .then(function(res) { 606 | var outputFile = res.trim(); 607 | return fs.read(outputFile).then(function(output) { 608 | ui.hideModal(); 609 | 610 | var wanInterface = output.match(/Detected WAN interface: (.+)/); 611 | var downloadSpeed = output.match(/Download speed: (.+) Mbit\/s/); 612 | var uploadSpeed = output.match(/Upload speed: (.+) Mbit\/s/); 613 | var downrate = output.match(/DOWNRATE: (.+) kbps/); 614 | var uprate = output.match(/UPRATE: (.+) kbps/); 615 | 616 | if (!downloadSpeed || !uploadSpeed || parseFloat(downloadSpeed[1]) <= 0 || parseFloat(uploadSpeed[1]) <= 0 || 617 | !downrate || !uprate || parseInt(downrate[1]) <= 0 || parseInt(uprate[1]) <= 0) { 618 | ui.addNotification(null, E('p', _('Invalid speed test results. Please try again or set values manually.')), 'error'); 619 | return; 620 | } 621 | var gamingRules = output.match(/Gaming device rules added for IP: (.+)/); 622 | 623 | ui.showModal(_(''), [ 624 | E('h2', { 'style': 'text-align:center; margin-bottom: 1em;' }, _('Auto Setup Results')), 625 | E('h3', { 'style': 'margin-bottom: 0.5em;' }, _('Speed Test Results')), 626 | E('p', { 'style': 'color: orange; margin-bottom: 1em;' }, _('Note: Router-based speed tests may underestimate actual speeds. For best results, consider running tests from a LAN device and manually entering the values. These results serve as a starting point.')), 627 | E('div', { 'style': 'display: table; width: 100%;' }, [ 628 | E('div', { 'style': 'display: table-row;' }, [ 629 | E('div', { 'style': 'display: table-cell; padding: 5px; font-weight: bold;' }, _('WAN Interface')), 630 | E('div', { 'style': 'display: table-cell; padding: 5px;' }, wanInterface ? wanInterface[1] : _('Not detected')) 631 | ]), 632 | E('div', { 'style': 'display: table-row;' }, [ 633 | E('div', { 'style': 'display: table-cell; padding: 5px; font-weight: bold;' }, _('Download Speed')), 634 | E('div', { 'style': 'display: table-cell; padding: 5px;' }, downloadSpeed ? downloadSpeed[1] + ' Mbit/s' : _('Not available')) 635 | ]), 636 | E('div', { 'style': 'display: table-row;' }, [ 637 | E('div', { 'style': 'display: table-cell; padding: 5px; font-weight: bold;' }, _('Upload Speed')), 638 | E('div', { 'style': 'display: table-cell; padding: 5px;' }, uploadSpeed ? uploadSpeed[1] + ' Mbit/s' : _('Not available')) 639 | ]) 640 | ]), 641 | E('h3', { 'style': 'margin-top: 1em; margin-bottom: 0.5em;' }, _('QoS Configuration')), 642 | E('div', { 'style': 'display: table; width: 100%;' }, [ 643 | E('div', { 'style': 'display: table-row;' }, [ 644 | E('div', { 'style': 'display: table-cell; padding: 5px; font-weight: bold;' }, _('Download Rate')), 645 | E('div', { 'style': 'display: table-cell; padding: 5px;' }, downrate ? downrate[1] + ' kbps' : _('Not set')) 646 | ]), 647 | E('div', { 'style': 'display: table-row;' }, [ 648 | E('div', { 'style': 'display: table-cell; padding: 5px; font-weight: bold;' }, _('Upload Rate')), 649 | E('div', { 'style': 'display: table-cell; padding: 5px;' }, uprate ? uprate[1] + ' kbps' : _('Not set')) 650 | ]) 651 | ]), 652 | gamingRules ? E('div', { 'style': 'margin-top: 1em;' }, [ 653 | E('div', { 'style': 'font-weight: bold;' }, _('Gaming Rules')), 654 | E('div', {}, _('Added for IP: ') + gamingRules[1]) 655 | ]) : '', 656 | E('div', { 'class': 'right', 'style': 'margin-top: 1em;' }, [ 657 | E('button', { 658 | 'class': 'btn cbi-button-action', 659 | 'click': ui.createHandlerFn(this, function() { 660 | ui.showModal(_('Applying Changes'), [ 661 | E('p', { 'class': 'spinning' }, _('Please wait while the changes are being applied...')) 662 | ]); 663 | 664 | var rootQdisc = uci.get('qosmate', 'settings', 'ROOT_QDISC'); 665 | var downrateValue = downrate ? parseInt(downrate[1]) : 0; 666 | var uprateValue = uprate ? parseInt(uprate[1]) : 0; 667 | 668 | if (rootQdisc === 'hfsc' && (downrateValue <= 0 || uprateValue <= 0)) { 669 | ui.hideModal(); 670 | ui.addNotification(null, E('p', _('Invalid rates for HFSC. Please set non-zero values manually.')), 'error'); 671 | } else { 672 | uci.set('qosmate', 'settings', 'DOWNRATE', downrateValue.toString()); 673 | uci.set('qosmate', 'settings', 'UPRATE', uprateValue.toString()); 674 | 675 | uci.save() 676 | .then(() => { 677 | return fs.exec_direct('/etc/init.d/qosmate', ['restart']); 678 | }) 679 | .then(() => { 680 | ui.hideModal(); 681 | ui.addNotification(null, E('p', _('QoSmate settings updated and service restarted.')), 'success'); 682 | window.setTimeout(function() { 683 | location.reload(); 684 | }, 2000); 685 | }) 686 | .catch(function(err) { 687 | ui.hideModal(); 688 | ui.addNotification(null, E('p', _('Failed to update settings or restart QoSmate: ') + err), 'error'); 689 | }); 690 | } 691 | }) 692 | }, _('Apply and Reload')) 693 | ]) 694 | ]); 695 | }); 696 | }) 697 | .catch(function(err) { 698 | ui.hideModal(); 699 | ui.addNotification(null, E('p', _('Auto setup failed: ') + err), 'error'); 700 | }); 701 | }) 702 | }, _('Start')) 703 | ]) 704 | ]); 705 | }); 706 | 707 | let s_basic = m.section(form.NamedSection, 'settings', 'settings', _('Basic Settings')); 708 | s_basic.anonymous = true; 709 | 710 | function createOption(name, title, description, placeholder, datatype) { 711 | var opt = s_basic.option(form.Value, name, title, description); 712 | opt.datatype = datatype || 'string'; 713 | opt.rmempty = true; 714 | opt.placeholder = placeholder; 715 | 716 | if (datatype === 'uinteger') { 717 | opt.validate = function(section_id, value) { 718 | if (value === '' || value === null) return true; 719 | if (!/^\d+$/.test(value)) return _('Must be a non-negative integer or empty'); 720 | var intValue = parseInt(value, 10); 721 | var rootQdisc = this.section.formvalue(section_id, 'ROOT_QDISC'); 722 | if (intValue === 0 && rootQdisc === 'hfsc') { 723 | return _('Value must be greater than 0 for HFSC'); 724 | } 725 | return true; 726 | }; 727 | } 728 | return opt; 729 | } 730 | 731 | var wanInterface = uci.get('qosmate', 'settings', 'WAN') || ''; 732 | o = s_basic.option(widgets.DeviceSelect, 'WAN', _('WAN Interface'), _('Select the WAN interface')); 733 | o.rmempty = false; 734 | o.editable = true; 735 | o.default = wanInterface; 736 | 737 | createOption('DOWNRATE', _('Download Rate (kbps)'), _('Set the download rate in kbps'), _('Default: 90000'), 'uinteger'); 738 | createOption('UPRATE', _('Upload Rate (kbps)'), _('Set the upload rate in kbps'), _('Default: 45000'), 'uinteger'); 739 | 740 | o = s_basic.option(form.ListValue, 'ROOT_QDISC', _('Root Queueing Discipline'), _('Select the root queueing discipline')); 741 | o.value('hfsc', _('HFSC')); 742 | o.value('cake', _('CAKE')); 743 | o.value('hybrid', _('Hybrid')); 744 | o.default = 'hfsc'; 745 | o.onchange = function(ev, section_id, value) { 746 | var downrate = this.map.lookupOption('DOWNRATE', section_id)[0]; 747 | var uprate = this.map.lookupOption('UPRATE', section_id)[0]; 748 | if (downrate && uprate) { 749 | downrate.map.checkDepends(); 750 | uprate.map.checkDepends(); 751 | } 752 | }; 753 | 754 | return m.render(); 755 | } 756 | }); 757 | 758 | function updateQosmate() { 759 | // Implement the update logic here 760 | ui.showModal(_('Updating QoSmate'), [ 761 | E('p', { 'class': 'spinning' }, _('Updating QoSmate. Please wait...')) 762 | ]); 763 | 764 | // Simulating an update process 765 | setTimeout(function() { 766 | ui.hideModal(); 767 | window.location.reload(); 768 | }, 5000); 769 | } 770 | -------------------------------------------------------------------------------- /po/README.md: -------------------------------------------------------------------------------- 1 | # QoSmate Translations 2 | 3 | This directory contains translations for the QoSmate LuCI application. 4 | 5 | ## Contributing Translations 6 | 7 | 1. Copy templates/qosmate.pot to xx.po (where xx is your language code) 8 | 2. Translate the strings in your xx.po file 9 | 3. Submit a pull request 10 | 11 | ## Available Languages 12 | - English (default) 13 | - German (de.po) (test) 14 | 15 | ## Creating/Updating Translations 16 | Use these commands to update translations: 17 | 18 | ```bash 19 | # Update .pot template 20 | ./scripts/i18n-scan.pl htdocs > po/templates/qosmate.pot 21 | 22 | # Update existing .po files 23 | ./scripts/i18n-update.pl po/templates/qosmate.pot po/*.po 24 | -------------------------------------------------------------------------------- /po/de.po: -------------------------------------------------------------------------------- 1 | msgid "" 2 | msgstr "" 3 | "Project-Id-Version: QoSmate\n" 4 | "PO-Revision-Date: 2024-01-09\n" 5 | "Last-Translator: Your Name\n" 6 | "Language: de\n" 7 | "MIME-Version: 1.0\n" 8 | "Content-Type: text/plain; charset=UTF-8\n" 9 | "Content-Transfer-Encoding: 8bit\n" 10 | 11 | #: htdocs/luci-static/resources/view/qosmate/settings.js:25 12 | msgid "QoSmate Settings" 13 | msgstr "QoSmate Einstellungen" 14 | 15 | #: htdocs/luci-static/resources/view/qosmate/settings.js:26 16 | msgid "Configure QoSmate settings." 17 | msgstr "Konfigurieren Sie die QoSmate-Einstellungen." 18 | 19 | #: htdocs/luci-static/resources/view/qosmate/hfsc.js:15 20 | msgid "HFSC Settings" 21 | msgstr "HFSC-Einstellungen" 22 | -------------------------------------------------------------------------------- /po/templates/qosmate.pot: -------------------------------------------------------------------------------- 1 | msgid "" 2 | msgstr "Content-Type: text/plain; charset=UTF-8" 3 | 4 | #: htdocs/luci-static/resources/view/qosmate/settings.js:25 5 | msgid "QoSmate Settings" 6 | msgstr "" 7 | 8 | #: htdocs/luci-static/resources/view/qosmate/settings.js:26 9 | msgid "Configure QoSmate settings." 10 | msgstr "" 11 | 12 | #: htdocs/luci-static/resources/view/qosmate/hfsc.js:15 13 | msgid "HFSC Settings" 14 | msgstr "" 15 | -------------------------------------------------------------------------------- /po/zh_Hans/qosmate.po: -------------------------------------------------------------------------------- 1 | "Content-Type: text/plain; charset=UTF-8\n" 2 | "Content-Transfer-Encoding: 8bit\n" 3 | "Language: zh_CN\n" 4 | 5 | msgid "Settings" 6 | msgstr "设置" 7 | 8 | msgid "Basic Settings" 9 | msgstr "基础设置" 10 | 11 | msgid "HFSC" 12 | msgstr "HFSC" 13 | 14 | msgid "CAKE" 15 | msgstr "CAKE" 16 | 17 | msgid "Advanced" 18 | msgstr "高级设置" 19 | 20 | msgid "Rules" 21 | msgstr "规则" 22 | 23 | msgid "Custom Rules" 24 | msgstr "自定义规则" 25 | 26 | msgid "Connections" 27 | msgstr "连接" 28 | 29 | msgid "QoSmate Settings" 30 | msgstr "QoSmate 设置" 31 | 32 | msgid "Configure QoSmate settings." 33 | msgstr "配置 QoSmate 设置。" 34 | 35 | msgid "Service Status" 36 | msgstr "服务状态" 37 | 38 | msgid "Running" 39 | msgstr "运行中" 40 | 41 | msgid "Stopped" 42 | msgstr "已停止" 43 | 44 | msgid "Service Control" 45 | msgstr "服务控制" 46 | 47 | msgid "Start" 48 | msgstr "启动" 49 | 50 | msgid "Restart" 51 | msgstr "重启" 52 | 53 | msgid "Stop" 54 | msgstr "停止" 55 | 56 | msgid "Auto Setup" 57 | msgstr "自动设置" 58 | 59 | msgid "Start Auto Setup" 60 | msgstr "开始自动设置" 61 | 62 | msgid "This will run a speed test and configure QoSmate automatically." 63 | msgstr "这将运行速度测试并自动配置 QoSmate。" 64 | 65 | msgid "Gaming Device IP (optional)" 66 | msgstr "游戏设备 IP(可选)" 67 | 68 | msgid "Invalid speed test results. Please try again or set values manually." 69 | msgstr "无效的速度测试结果。请重试或手动设置值。" 70 | 71 | msgid "QoSmate settings updated and service restarted." 72 | msgstr "QoSmate 设置已更新,服务已重启。" 73 | 74 | msgid "Failed to start QoSmate" 75 | msgstr "启动 QoSmate 失败" 76 | 77 | msgid "Failed to restart QoSmate" 78 | msgstr "重启 QoSmate 失败" 79 | 80 | msgid "QoSmate stopped" 81 | msgstr "QoSmate 已停止" 82 | 83 | msgid "QoSmate started" 84 | msgstr "QoSmate 已启用" 85 | 86 | msgid "Failed to stop QoSmate" 87 | msgstr "停止 QoSmate 失败" 88 | 89 | msgid "Version Information" 90 | msgstr "版本信息" 91 | 92 | msgid "Unable to fetch" 93 | msgstr "获取失败" 94 | 95 | msgid "Current Version" 96 | msgstr "当前版本" 97 | 98 | msgid "Latest Version" 99 | msgstr "最新版本" 100 | 101 | msgid "A new version is available!" 102 | msgstr "有新版本可用!" 103 | 104 | msgid "QoSmate is up to date." 105 | msgstr "QoSmate 已是最新" 106 | 107 | msgid "Unable to check for updates." 108 | msgstr "检查更新失败" 109 | 110 | msgid "Enable" 111 | msgstr "启用" 112 | 113 | msgid "Enable or disable qosmate" 114 | msgstr "启用或禁用 QoSmate" 115 | 116 | msgid "WAN Interface" 117 | msgstr "WAN 接口" 118 | 119 | msgid "Select the WAN interface" 120 | msgstr "选择 WAN 接口" 121 | 122 | msgid "Download Rate (kbps)" 123 | msgstr "下载速度 (kbps)" 124 | 125 | msgid "Set the download rate in kbps" 126 | msgstr "设置下载速率(kbps)" 127 | 128 | msgid "Upload Rate (kbps)" 129 | msgstr "上传速度 (kbps)" 130 | 131 | msgid "Set the upload rate in kbps" 132 | msgstr "设置上传速率(kbps)" 133 | 134 | msgid "Root Queueing Discipline" 135 | msgstr "根队列管理策略" 136 | 137 | msgid "Select the root queueing discipline" 138 | msgstr "选择根队列管理策略" 139 | 140 | msgid "Please set non-zero values manually." 141 | msgstr "请手动设置非零值。" 142 | 143 | msgid "QoSmate HFSC Settings" 144 | msgstr "QoSmate HFSC 设置" 145 | 146 | msgid "Configure HFSC settings for QoSmate." 147 | msgstr "配置 QoSmate 的 HFSC 设置。" 148 | 149 | msgid "HFSC Settings" 150 | msgstr "HFSC 设置" 151 | 152 | msgid "Link Type" 153 | msgstr "链路类型" 154 | 155 | msgid "Select the link type" 156 | msgstr "选择链路类型" 157 | 158 | msgid "Overhead" 159 | msgstr "开销" 160 | 161 | msgid "Set the overhead" 162 | msgstr "设置开销" 163 | 164 | msgid "Default: 44" 165 | msgstr "默认值: 44" 166 | 167 | msgid "Game Queue Discipline" 168 | msgstr "游戏队列机制" 169 | 170 | msgid "Queueing method for traffic classified as realtime" 171 | msgstr "分类为实时流量的队列方法" 172 | 173 | msgid "Game Upload (kbps)" 174 | msgstr "游戏上传速率(kbps)" 175 | 176 | msgid "Bandwidth reserved for realtime upload traffic" 177 | msgstr "为实时上传流量保留的带宽" 178 | 179 | msgid "Default: 15% of UPRATE + 400" 180 | msgstr "默认值: 上传速度的 15% + 400" 181 | 182 | msgid "Default: 15% of DOWNRATE + 400" 183 | msgstr "默认值: 下载速度的 15% + 400" 184 | 185 | msgid "Game Download (kbps)" 186 | msgstr "游戏下载速率(kbps)" 187 | 188 | msgid "Bandwidth reserved for realtime download traffic" 189 | msgstr "为实时下载流量保留的带宽" 190 | 191 | msgid "Non-Game Queue Discipline" 192 | msgstr "非游戏队列机制" 193 | 194 | msgid "Select the queueing discipline for non-realtime traffic" 195 | msgstr "为非实时流量选择队列机制" 196 | 197 | msgid "Non-Game QDisc Options" 198 | msgstr "非游戏队列选项" 199 | 200 | msgid "Cake options for non-realtime queueing discipline" 201 | msgstr "非实时队列机制的 Cake 选项" 202 | 203 | msgid "Default: besteffort ack-filter" 204 | msgstr "默认值: besteffort ack-filter" 205 | 206 | msgid "Max Delay (ms)" 207 | msgstr "最大延迟(毫秒)" 208 | 209 | msgid "Target max delay for realtime packets after burst (pfifo, bfifo, red)" 210 | msgstr "突发后实时数据包的目标最大延迟 (pfifo, bfifo, red)" 211 | 212 | msgid "PFIFO Min" 213 | msgstr "PFIFO 最小值" 214 | 215 | msgid "Minimum packet count for PFIFO queue" 216 | msgstr "PFIFO 队列的最小数据包数" 217 | 218 | msgid "Avg Packet Size (B)" 219 | msgstr "平均数据包大小(字节)" 220 | 221 | msgid "Used with PFIFOMIN to calculate PFIFO limit" 222 | msgstr "与 PFIFOMIN 一起使用以计算 PFIFO 限制" 223 | 224 | msgid "NETEM Delay (ms)" 225 | msgstr "NETEM 延迟(毫秒)" 226 | 227 | msgid "NETEM delay in milliseconds" 228 | msgstr "NETEM 的延迟,以毫秒为单位" 229 | 230 | msgid "NETEM Jitter (ms)" 231 | msgstr "NETEM 抖动(毫秒)" 232 | 233 | msgid "NETEM jitter in milliseconds" 234 | msgstr "NETEM 的抖动,以毫秒为单位" 235 | 236 | msgid "NETEM Distribution" 237 | msgstr "NETEM 分布" 238 | 239 | msgid "NETEM delay distribution" 240 | msgstr "NETEM 延迟分布" 241 | 242 | msgid "Packet Loss Percentage" 243 | msgstr "数据包丢失百分比" 244 | 245 | msgid "Percentage of packet loss" 246 | msgstr "数据包丢失百分比" 247 | 248 | msgid "Failed to save settings or update QoSmate service: " 249 | msgstr "保存设置或更新 QoSmate 服务失败:" 250 | 251 | msgid "QoSmate CAKE Settings" 252 | msgstr "QoSmate CAKE 设置" 253 | 254 | msgid "Configure CAKE settings for QoSmate." 255 | msgstr "配置 QoSmate 的 CAKE 设置。" 256 | 257 | msgid "CAKE Settings" 258 | msgstr "CAKE 设置" 259 | 260 | msgid "Common Link Presets" 261 | msgstr "常见链路预设" 262 | 263 | msgid "Select common link presets" 264 | msgstr "选择常见链路预设" 265 | 266 | msgid "Raw (No overhead compensation)" 267 | msgstr "原始(无开销补偿)" 268 | 269 | msgid "Conservative (48 bytes overhead + ATM)" 270 | msgstr "保守(48 字节开销 + ATM)" 271 | 272 | msgid "Ethernet" 273 | msgstr "以太网" 274 | 275 | msgid "DOCSIS cable" 276 | msgstr "DOCSIS 电缆" 277 | 278 | msgid "PPPoA VC-Mux" 279 | msgstr "PPPoA VC-Mux" 280 | 281 | msgid "PPPoA LLC" 282 | msgstr "PPPoA LLC" 283 | 284 | msgid "PPPoE VC-Mux" 285 | msgstr "PPPoE VC-Mux" 286 | 287 | msgid "PPPoE LLC-SNAP" 288 | msgstr "PPPoE LLC-SNAP" 289 | 290 | msgid "Bridged VC-Mux" 291 | msgstr "桥接 VC-Mux" 292 | 293 | msgid "Bridged LLC-SNAP" 294 | msgstr "桥接 LLC-SNAP" 295 | 296 | msgid "IPoA VC-Mux" 297 | msgstr "IPoA VC-Mux" 298 | 299 | msgid "IPoA LLC-SNAP" 300 | msgstr "IPoA LLC-SNAP" 301 | 302 | msgid "PPPoE PTM" 303 | msgstr "PPPoE PTM" 304 | 305 | msgid "Bridged PTM" 306 | msgstr "桥接 PTM" 307 | 308 | msgid "Set the overhead" 309 | msgstr "设置开销" 310 | 311 | msgid "Default: based on preset" 312 | msgstr "默认值: 基于预设" 313 | 314 | msgid "MPU" 315 | msgstr "MPU" 316 | 317 | msgid "Minimum packet size CAKE will account for" 318 | msgstr "CAKE 将考虑的最小数据包大小" 319 | 320 | msgid "Link Compensation" 321 | msgstr "链路补偿" 322 | 323 | msgid "Set the link compensation" 324 | msgstr "设置链路补偿" 325 | 326 | msgid "Ether VLAN Keyword" 327 | msgstr "Ether VLAN 关键字" 328 | 329 | msgid "Set the Ether VLAN keyword" 330 | msgstr "设置 Ether VLAN 关键字" 331 | 332 | msgid "Priority Queue (Ingress)" 333 | msgstr "优先级队列(入口)" 334 | 335 | msgid "Sets CAKE's diffserv mode for incoming traffic" 336 | msgstr "为入站流量设置 CAKE 的 diffserv 模式" 337 | 338 | msgid "Diffserv 3-tier priority" 339 | msgstr "Diffserv 3 级优先级" 340 | 341 | msgid "Diffserv 4-tier priority" 342 | msgstr "Diffserv 4 级优先级" 343 | 344 | msgid "Diffserv 8-tier priority" 345 | msgstr "Diffserv 8 级优先级" 346 | 347 | msgid "Priority Queue (Egress)" 348 | msgstr "优先级队列(出口)" 349 | 350 | msgid "Sets CAKE's diffserv mode for outgoing traffic" 351 | msgstr "为出站流量设置 CAKE 的 diffserv 模式" 352 | 353 | msgid "Host Isolation" 354 | msgstr "主机隔离" 355 | 356 | msgid "Applies fairness first by host, then by flow(dual-srchost/dual-dsthost)" 357 | msgstr "首先按主机,然后按流量应用公平性 (dual-srchost/dual-dsthost)" 358 | 359 | msgid "NAT (Ingress)" 360 | msgstr "NAT(入口)" 361 | 362 | msgid "Enable NAT lookup for ingress" 363 | msgstr "为入站启用 NAT 查找" 364 | 365 | msgid "NAT (Egress)" 366 | msgstr "NAT(出口)" 367 | 368 | msgid "Enable NAT lookup for egress" 369 | msgstr "为出站启用 NAT 查找" 370 | 371 | msgid "ACK Filter (Egress)" 372 | msgstr "ACK 过滤器(出口)" 373 | 374 | msgid "Set ACK filter for egress. Auto enables filtering if download/upload ratio ≥ 15." 375 | msgstr "为出口设置 ACK 过滤器。如果下载/上传比率≥15,将自动启用过滤。" 376 | 377 | msgid "Auto" 378 | msgstr "自动" 379 | 380 | msgid "Enable" 381 | msgstr "启用" 382 | 383 | msgid "Disable" 384 | msgstr "禁用" 385 | 386 | msgid "RTT" 387 | msgstr "RTT" 388 | 389 | msgid "Default: auto" 390 | msgstr "默认值:自动" 391 | 392 | msgid "Set the Round Trip Time" 393 | msgstr "设置往返时间" 394 | 395 | msgid "Autorate (Ingress)" 396 | msgstr "自动速率(入口)" 397 | 398 | msgid "Enable autorate for ingress" 399 | msgstr "为入站启用自动速率" 400 | 401 | msgid "Extra Parameters (Ingress)" 402 | msgstr "额外参数(入口)" 403 | 404 | msgid "Set extra parameters for ingress" 405 | msgstr "设置入站的额外参数" 406 | 407 | msgid "Extra Parameters (Egress)" 408 | msgstr "额外参数(出口)" 409 | 410 | msgid "Set extra parameters for egress" 411 | msgstr "设置出站的额外参数" 412 | 413 | msgid "Failed to save settings or update QoSmate service: " 414 | msgstr "保存设置或更新 QoSmate 服务失败:" 415 | 416 | msgid "QoSmate Advanced Settings" 417 | msgstr "QoSmate 高级设置" 418 | 419 | msgid "Configure advanced settings for QoSmate." 420 | msgstr "配置 QoSmate 的高级设置。" 421 | 422 | msgid "Advanced Settings" 423 | msgstr "高级设置" 424 | 425 | msgid "Preserve Config Files" 426 | msgstr "保留配置文件" 427 | 428 | msgid "Preserve configuration files during system upgrade" 429 | msgstr "系统升级时保留配置文件" 430 | 431 | msgid "Wash DSCP Egress" 432 | msgstr "清除 DSCP(出口)" 433 | 434 | msgid "Sets DSCP to CS0 for outgoing packets after classification" 435 | msgstr "分类后将出口数据包的 DSCP 设置为 CS0" 436 | 437 | msgid "Wash DSCP Ingress" 438 | msgstr "清除 DSCP(入口)" 439 | 440 | msgid "Sets DSCP to CS0 for incoming packets before classification" 441 | msgstr "分类前将入口数据包的 DSCP 设置为 CS0" 442 | 443 | msgid "Bandwidth Max Ratio" 444 | msgstr "带宽最大比例" 445 | 446 | msgid "Max download/upload ratio to prevent upstream congestion" 447 | msgstr "最大下载/上传比例,以防止上游拥塞" 448 | 449 | msgid "Default: 20" 450 | msgstr "默认值:20" 451 | 452 | msgid "ACK Rate" 453 | msgstr "ACK 速率" 454 | 455 | msgid "Sets rate limit for TCP ACKs, helps prevent ACK flooding / set to 0 to disable ACK rate limit" 456 | msgstr "设置 TCP ACK 的速率限制,帮助防止 ACK 泛洪 / 设为 0 以禁用 ACK 速率限制" 457 | 458 | msgid "Default: 5% of UPRATE" 459 | msgstr "默认值:上传速率的 5%" 460 | 461 | msgid "Enable UDP Rate Limit" 462 | msgstr "启用 UDP 速率限制" 463 | 464 | msgid "Downgrades UDP traffic exceeding 450 pps to lower priority" 465 | msgstr "将超过 450 pps 的 UDP 流量降级为低优先级" 466 | 467 | msgid "Boost Low-Volume TCP Traffic" 468 | msgstr "提升小流量 TCP 流量" 469 | 470 | msgid "Upgrade DSCP to AF42 for TCP connections with less than 150 packets per second. This can improve responsiveness for interactive TCP services like SSH, web browsing, and instant messaging." 471 | msgstr "将每秒小于 150 个数据包的 TCP 连接的 DSCP 升级到 AF42。这样可以提高 SSH、网页浏览和即时消息等交互式 TCP 服务的响应速度。" 472 | 473 | msgid "UDP Bulk Ports" 474 | msgstr "UDP 批量端口" 475 | 476 | msgid "Specify UDP ports for bulk traffic" 477 | msgstr "指定用于批量流量的 UDP 端口" 478 | 479 | msgid "Default: none" 480 | msgstr "默认值:无" 481 | 482 | msgid "TCP Bulk Ports" 483 | msgstr "TCP 批量端口" 484 | 485 | msgid "Specify TCP ports for bulk traffic" 486 | msgstr "指定用于批量流量的 TCP 端口" 487 | 488 | msgid "TCP MSS" 489 | msgstr "TCP MSS" 490 | 491 | msgid "Nftables Hook" 492 | msgstr "Nftables 钩子" 493 | 494 | msgid "Select the nftables hook point for the dscptag chain" 495 | msgstr "为 dscptag 链选择 nftables 钩子点" 496 | 497 | msgid "Nftables Priority" 498 | msgstr "Nftables 优先级" 499 | 500 | msgid "Set the priority for the nftables chain. Lower values are processed earlier. Default is 0 | mangle is -150." 501 | msgstr "为 nftables 链选择优先级。数值越低,处理优先级越高。默认为0,mangle表为 -150。" 502 | 503 | msgid "Maximum Segment Size for TCP connections. This setting is only active when the upload or download bandwidth is less than 3000 kbit/s. Leave empty to use the default value." 504 | msgstr "TCP 连接的最大段大小。此设置仅在上传或下载带宽小于 3000 kbit/s 时生效。留空将使用默认值。" 505 | 506 | msgid "Default: 536" 507 | msgstr "默认值:536" 508 | 509 | msgid "Failed to save settings or update QoSmate service: " 510 | msgstr "保存设置或更新 QoSmate 服务失败:" 511 | 512 | msgid "QoSmate Rules" 513 | msgstr "QoSmate 规则" 514 | 515 | msgid "Configure QoS rules for marking packets with DSCP values." 516 | msgstr "配置 QoS 规则以标记具有 DSCP 值的数据包。" 517 | 518 | msgid "Rules" 519 | msgstr "规则" 520 | 521 | msgid "General Settings" 522 | msgstr "常规设置" 523 | 524 | msgid "DSCP Mapping" 525 | msgstr "DSCP 映射" 526 | 527 | msgid "HFSC Mapping:" 528 | msgstr "HFSC 映射:" 529 | 530 | msgid "High Priority [Realtime] (1:11)" 531 | msgstr "高优先级 [实时] (1:11)" 532 | 533 | msgid "EF, CS5, CS6, CS7" 534 | msgstr "EF, CS5, CS6, CS7" 535 | 536 | msgid "Fast Non-Realtime (1:12)" 537 | msgstr "快速非实时 (1:12)" 538 | 539 | msgid "CS4, AF41, AF42" 540 | msgstr "CS4, AF41, AF42" 541 | 542 | msgid "Normal (1:13)" 543 | msgstr "普通 (1:13)" 544 | 545 | msgid "CS0" 546 | msgstr "CS0" 547 | 548 | msgid "Low Priority (1:14)" 549 | msgstr "低优先级 (1:14)" 550 | 551 | msgid "CS2" 552 | msgstr "CS2" 553 | 554 | msgid "Bulk (1:15)" 555 | msgstr "批量 (1:15)" 556 | 557 | msgid "CS1" 558 | msgstr "CS1" 559 | 560 | msgid "CAKE Mapping (diffserv4):" 561 | msgstr "CAKE 映射 (diffserv4):" 562 | 563 | msgid "Voice (Highest Priority)" 564 | msgstr "语音 (最高优先级)" 565 | 566 | msgid "CS7, CS6, EF, VA, CS5, CS4" 567 | msgstr "CS7, CS6, EF, VA, CS5, CS4" 568 | 569 | msgid "Video" 570 | msgstr "视频" 571 | 572 | msgid "CS3, AF4x, AF3x, CS2, TOS1" 573 | msgstr "CS3, AF4x, AF3x, CS2, TOS1" 574 | 575 | msgid "Best Effort" 576 | msgstr "最佳努力" 577 | 578 | msgid "CS0, AF1x, AF2x, TOS0" 579 | msgstr "CS0, AF1x, AF2x, TOS0" 580 | 581 | msgid "Bulk (Lowest Priority)" 582 | msgstr "批量 (最低优先级)" 583 | 584 | msgid "CS1, LE" 585 | msgstr "CS1, LE" 586 | 587 | msgid "Name" 588 | msgstr "名称" 589 | 590 | msgid "Protocol" 591 | msgstr "协议" 592 | 593 | msgid "TCP" 594 | msgstr "TCP" 595 | 596 | msgid "UDP" 597 | msgstr "UDP" 598 | 599 | msgid "ICMP" 600 | msgstr "ICMP" 601 | 602 | msgid "Any" 603 | msgstr "任意" 604 | 605 | msgid "Source IP" 606 | msgstr "源 IP" 607 | 608 | msgid "any" 609 | msgstr "任意" 610 | 611 | msgid "Invalid IP address or hostname" 612 | msgstr "无效的 IP 地址或主机名" 613 | 614 | msgid "Source port" 615 | msgstr "源端口" 616 | 617 | msgid "Invalid port or port range" 618 | msgstr "无效的端口或端口范围" 619 | 620 | msgid "Destination IP" 621 | msgstr "目的 IP" 622 | 623 | msgid "Destination port" 624 | msgstr "目的端口" 625 | 626 | msgid "DSCP Class" 627 | msgstr "DSCP 类别" 628 | 629 | msgid "EF - Expedited Forwarding (46)" 630 | msgstr "EF - 加速转发 (46)" 631 | 632 | msgid "CS5 (40)" 633 | msgstr "CS5 (40)" 634 | 635 | msgid "CS6 (48)" 636 | msgstr "CS6 (48)" 637 | 638 | msgid "CS7 (56)" 639 | msgstr "CS7 (56)" 640 | 641 | msgid "CS4 (32)" 642 | msgstr "CS4 (32)" 643 | 644 | msgid "AF41 (34)" 645 | msgstr "AF41 (34)" 646 | 647 | msgid "AF42 (36)" 648 | msgstr "AF42 (36)" 649 | 650 | msgid "CS2 (16)" 651 | msgstr "CS2 (16)" 652 | 653 | msgid "CS1 (8)" 654 | msgstr "CS1 (8)" 655 | 656 | msgid "CS0 - Best Effort (0)" 657 | msgstr "CS0 - 最佳努力 (0)" 658 | 659 | msgid "Enable counter" 660 | msgstr "启用计数器" 661 | 662 | msgid "Enable" 663 | msgstr "启用" 664 | 665 | msgid "Failed to save settings or update QoSmate service: " 666 | msgstr "保存设置或更新 QoSmate 服务失败:" 667 | 668 | msgid "Custom rules have been saved and applied." 669 | msgstr "自定义规则已保存并应用。" 670 | 671 | msgid "Failed to save settings or restart QoSmate:" 672 | msgstr "无法保存设置或重启 QoSmate:" 673 | 674 | msgid "QoSmate Custom Rules" 675 | msgstr "QoSmate 自定义规则" 676 | 677 | msgid "Define custom nftables rules for advanced traffic control." 678 | msgstr "定义用于高级流量控制的自定义 nftables 规则。" 679 | 680 | msgid "Erase Rules" 681 | msgstr "清除规则" 682 | 683 | msgid "Erase Custom Rules" 684 | msgstr "清除自定义规则" 685 | 686 | msgid "Are you sure you want to erase all custom rules? This action cannot be undone." 687 | msgstr "确定要清除所有自定义规则吗?此操作无法撤销。" 688 | 689 | msgid "Custom rules have been erased and changes applied." 690 | msgstr "自定义规则已清除并应用更改。" 691 | 692 | msgid "Failed to erase custom rules or apply changes:" 693 | msgstr "无法清除自定义规则或应用更改:" 694 | 695 | msgid "Custom nftables Rules" 696 | msgstr "自定义 nftables 规则" 697 | 698 | msgid "Enter your custom nftables rules here. The \"table inet qosmate_custom { ... }\" wrapper will be added automatically." 699 | msgstr "在此处输入您的自定义 nftables 规则。\"table inet qosmate_custom { ... }\" 包装器将被自动添加。" 700 | 701 | msgid "Custom rules validation successful." 702 | msgstr "自定义规则验证成功。" 703 | 704 | msgid "Custom rules validation failed. Please check the validation result below." 705 | msgstr "自定义规则验证失败。请检查下方的验证结果。" 706 | 707 | msgid "Validation Result" 708 | msgstr "验证结果" 709 | 710 | msgid "No validation performed yet" 711 | msgstr "还未进行任何验证" 712 | 713 | msgid "Validate Rules" 714 | msgstr "验证规则" 715 | 716 | msgid "Validate" 717 | msgstr "验证" 718 | 719 | msgid "Rules Information" 720 | msgstr "规则信息" 721 | 722 | msgid "Error: Could not find custom rules textarea" 723 | msgstr "错误:找不到自定义规则文本区域" 724 | 725 | msgid "Validating Rules" 726 | msgstr "正在验证规则" 727 | 728 | msgid "Please wait while the rules are being validated..." 729 | msgstr "请等待规则验证... " 730 | 731 | msgid "Finalizing validation results, please wait..." 732 | msgstr "正在完成验证结果,请稍候..." 733 | 734 | msgid "Error during validation:" 735 | msgstr "验证过程中出错:" 736 | 737 | msgid "Example rules:" 738 | msgstr "示例规则:" 739 | 740 | msgid "Warning:" 741 | msgstr "警告: " 742 | 743 | msgid "Incorrect rules can disrupt network functionality. Use with caution." 744 | msgstr "不正确的规则可能会破坏网络功能。请谨慎使用。" 745 | 746 | msgid "QoSmate Connections" 747 | msgstr "QoSmate 连接" 748 | 749 | msgid "Filter by IP, IP:Port, Port, Protocol or DSCP" 750 | msgstr "通过 IP、IP:端口、端口、协议或 DSCP 过滤" 751 | 752 | msgid "Zoom:" 753 | msgstr "缩放:" 754 | 755 | msgid "In: " 756 | msgstr "入站:" 757 | 758 | msgid "Out: " 759 | msgstr "出站:" 760 | 761 | msgid "Packets" 762 | msgstr "数据包" 763 | 764 | msgid "Avg PPS" 765 | msgstr "平均 PPS" 766 | 767 | msgid "Max PPS" 768 | msgstr "最大 PPS" 769 | 770 | msgid "Avg BPS" 771 | msgstr "平均 BPS" 772 | 773 | msgid "Protocol" 774 | msgstr "协议" 775 | 776 | msgid "Source" 777 | msgstr "来源" 778 | 779 | msgid "Destination" 780 | msgstr "目的地" 781 | 782 | msgid "DSCP" 783 | msgstr "DSCP" 784 | 785 | msgid "Bytes" 786 | msgstr "字节" 787 | -------------------------------------------------------------------------------- /root/usr/libexec/rpcd/luci.qosmate: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env lua 2 | 3 | local jsonc = require "luci.jsonc" 4 | 5 | -- Check if an IP address is private - not needed at the moment 6 | local function is_private_ip(ip) 7 | if not ip or ip == "" then 8 | return false 9 | end 10 | 11 | if ip:match(":") then -- IPv6 12 | -- Check for ULA (fc00::/7), link-local (fe80::/10), or loopback (::1) 13 | return ip:match("^f[cd]") or ip:match("^fe80:") or ip == "::1" 14 | else -- IPv4 15 | local octets = {ip:match("(%d+)%.(%d+)%.(%d+)%.(%d+)")} 16 | if not octets[1] then return false end 17 | local first, second = tonumber(octets[1]), tonumber(octets[2]) 18 | -- Check for private IPv4 ranges: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 19 | return (first == 10) or 20 | (first == 172 and second >= 16 and second <= 31) or 21 | (first == 192 and second == 168) 22 | end 23 | end 24 | 25 | -- Parse a single connection line from nf_conntrack 26 | local function parse_connection(line) 27 | local conn = {} 28 | conn.layer3, conn.layer4, conn.protocol, conn.timeout = line:match("(%w+)%s+(%d+)%s+(%w+)%s+(%d+)") 29 | if not (conn.layer3 and conn.layer4 and conn.protocol and conn.timeout) then 30 | return nil 31 | end 32 | 33 | if conn.protocol == "icmp" or conn.protocol == "icmpv6" then 34 | -- Handle ICMP and ICMPv6 protocols 35 | conn.src, conn.dst, conn.type, conn.code, conn.id = 36 | line:match("src=(%S+)%s+dst=(%S+)%s+type=(%d+)%s+code=(%d+)%s+id=(%d+)") 37 | conn.in_packets, conn.in_bytes = line:match("packets=(%d+)%s+bytes=(%d+)") 38 | conn.out_packets, conn.out_bytes = conn.in_packets, conn.in_bytes 39 | conn.sport, conn.dport = "-", "-" -- ICMP doesn't use ports 40 | else 41 | -- Handle other protocols (e.g., TCP, UDP) 42 | local src1, dst1, sport1, dport1, packets1, bytes1, 43 | src2, dst2, sport2, dport2, packets2, bytes2 = 44 | line:match("src=(%S+)%s+dst=(%S+)%s+sport=(%d+)%s+dport=(%d+)%s+packets=(%d+)%s+bytes=(%d+).*src=(%S+)%s+dst=(%S+)%s+sport=(%d+)%s+dport=(%d+)%s+packets=(%d+)%s+bytes=(%d+)") 45 | 46 | -- Always use the first direction as the original 47 | conn.src, conn.dst, conn.sport, conn.dport = src1, dst1, sport1, dport1 48 | conn.out_packets, conn.in_packets = tonumber(packets1), tonumber(packets2) 49 | conn.out_bytes, conn.in_bytes = tonumber(bytes1), tonumber(bytes2) 50 | end 51 | 52 | if not (conn.src and conn.dst) then 53 | return nil 54 | end 55 | 56 | -- Extract additional connection information 57 | conn.dscp = math.floor(tonumber(line:match("mark=(%d+)") or "0")) 58 | conn.use = tonumber(line:match("use=(%d+)") or "0") 59 | conn.timeout = tonumber(conn.timeout) or 0 60 | 61 | -- Determine connection state 62 | if line:match("%[ASSURED%]") then 63 | conn.state = "ASSURED" 64 | elseif line:match("%[UNREPLIED%]") then 65 | conn.state = "UNREPLIED" 66 | else 67 | conn.state = "UNKNOWN" 68 | end 69 | 70 | return conn 71 | end 72 | 73 | -- Retrieve all current connections from nf_conntrack 74 | local function get_connections() 75 | local conn_list = {} 76 | local f = io.open("/proc/net/nf_conntrack", "r") 77 | if not f then 78 | return {} 79 | end 80 | 81 | -- Read all connections from nf_conntrack 82 | for line in f:lines() do 83 | local conn = parse_connection(line) 84 | if conn then 85 | conn.total_bytes = (conn.in_bytes or 0) + (conn.out_bytes or 0) 86 | table.insert(conn_list, conn) 87 | end 88 | end 89 | f:close() 90 | 91 | -- Sort the entire list in descending order by total_bytes 92 | table.sort(conn_list, function(a, b) 93 | return a.total_bytes > b.total_bytes 94 | end) 95 | 96 | -- Determine max_entries based on system load 97 | local load_avg = io.open("/proc/loadavg"):read("*a") 98 | local load1 = tonumber(load_avg:match("^(%d+%.%d+)")) or 0 99 | 100 | -- Default: no limit 101 | local max_entries = math.huge 102 | 103 | -- Simple thresholds based on absolute load 104 | if load1 > 2.0 then 105 | max_entries = 100 106 | -- io.popen("logger -t qosmate 'Critical load! Limiting to 100 connections'") 107 | elseif load1 > 1.5 then 108 | max_entries = 500 109 | -- io.popen("logger -t qosmate 'High load! Limiting to 500 connections'") 110 | elseif load1 > 0.8 then 111 | max_entries = 1000 112 | -- io.popen("logger -t qosmate 'Moderate load! Limiting to 1000 connections'") 113 | end 114 | 115 | -- Final connections table 116 | local connections = {} 117 | for i = 1, math.min(max_entries, #conn_list) do 118 | local conn = conn_list[i] 119 | local key = string.format("%s:%s:%s:%s:%s:%s", 120 | conn.layer3, conn.protocol, conn.src, conn.sport, conn.dst, conn.dport) 121 | connections[key] = conn 122 | end 123 | 124 | return connections 125 | end 126 | 127 | -- Define RPC methods 128 | local methods = { 129 | getConntrackDSCP = { 130 | call = function() 131 | local connections = get_connections() 132 | return {result = jsonc.stringify({connections = connections})} 133 | end 134 | } 135 | } 136 | 137 | -- Handle RPC calls 138 | if arg[1] == "list" then 139 | local rv = {} 140 | for _, v in pairs(methods) do 141 | rv[_] = v.args or {} 142 | end 143 | print((jsonc.stringify(rv):gsub(":%[%]", ":{}"))) 144 | elseif arg[1] == "call" then 145 | local args = jsonc.parse(io.stdin:read("*a")) 146 | local method = methods[arg[2]] 147 | if method then 148 | local result = method.call(args) 149 | print(result.result) 150 | os.exit(result.code or 0) 151 | else 152 | print(jsonc.stringify({error = "Method not found"})) 153 | os.exit(1) 154 | end 155 | end 156 | -------------------------------------------------------------------------------- /root/usr/libexec/rpcd/luci.qosmate_stats: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # QoSmate Statistics Backend for LuCI 4 | # shellcheck disable=SC2039,SC3043,SC2155,SC3057,SC1091 5 | 6 | . /lib/functions.sh 7 | 8 | # Set to 1 to enable debug logging, 0 to disable 9 | DEBUG=0 10 | 11 | # Debug logging function 12 | debug_log() { 13 | if [ "$DEBUG" -eq 1 ]; then 14 | echo "$1" >> /tmp/qosmate_debug.log 15 | fi 16 | } 17 | 18 | # Function to safely get JSON from tc command 19 | get_tc_json() { 20 | local output 21 | # Fix HFSC options format by completely replacing the options object 22 | output=$("$@" 2>/dev/null) || echo "[]" 23 | 24 | # Check if output is empty 25 | if [ -z "$output" ]; then 26 | echo "[]" 27 | return 28 | fi 29 | 30 | # Fix the HFSC options format by replacing the entire options object with a simple default value 31 | echo "$output" | sed 's/\("kind":"hfsc",[^{]*"options":\){[^}]*}/\1{"default":13}/g' 32 | } 33 | 34 | # Function to filter statistics to only include QoSmate relevant qdiscs 35 | filter_qosmate_qdiscs() { 36 | local stats="$1" 37 | local wan_interface="$2" 38 | local ifb_interface="$3" 39 | 40 | # Filter to only include qdiscs related to QoSmate (on wan_interface and ifb_interface) 41 | echo "$stats" | jq -c "[.[] | select(.dev == \"$wan_interface\" or .dev == \"$ifb_interface\")]" 2>/dev/null || echo "[]" 42 | } 43 | 44 | # Function to get the statistics based on root qdisc 45 | get_stats() { 46 | # Get basic statistics for all qdiscs 47 | local basic_stats 48 | basic_stats=$(get_tc_json tc -s -j qdisc show) 49 | 50 | debug_log "Basic stats: $basic_stats" 51 | 52 | # Get root qdisc type 53 | local root_qdisc 54 | root_qdisc=$(uci -q get qosmate.settings.ROOT_QDISC || echo "hfsc") 55 | 56 | # Get interface names 57 | local wan_interface 58 | wan_interface=$(uci -q get qosmate.settings.WAN || echo "eth1") 59 | 60 | local ifb_interface 61 | ifb_interface="ifb-$wan_interface" 62 | 63 | # Filter basic stats to only include QoSmate relevant qdiscs 64 | local filtered_stats 65 | filtered_stats=$(filter_qosmate_qdiscs "$basic_stats" "$wan_interface" "$ifb_interface") 66 | debug_log "Filtered stats: $filtered_stats" 67 | 68 | # Process statistics based on qdisc type 69 | local result 70 | if [ "$root_qdisc" = "cake" ]; then 71 | # Extract CAKE statistics for both egress and ingress 72 | local cake_egress_stats 73 | cake_egress_stats=$(echo "$filtered_stats" | jq -c "[.[] | select(.kind == \"cake\" and .dev == \"$wan_interface\")]" 2>/dev/null || echo "[]") 74 | debug_log "Cake egress stats: $cake_egress_stats" 75 | 76 | local cake_ingress_stats 77 | cake_ingress_stats=$(echo "$filtered_stats" | jq -c "[.[] | select(.kind == \"cake\" and .dev == \"$ifb_interface\")]" 2>/dev/null || echo "[]") 78 | debug_log "Cake ingress stats: $cake_ingress_stats" 79 | 80 | # Get the priority queue type (diffserv3/4/8) 81 | local priority_queue_ingress 82 | priority_queue_ingress=$(uci -q get qosmate.cake.PRIORITY_QUEUE_INGRESS || echo "diffserv4") 83 | local priority_queue_egress 84 | priority_queue_egress=$(uci -q get qosmate.cake.PRIORITY_QUEUE_EGRESS || echo "diffserv4") 85 | 86 | # Extract the actual cake qdisc stats for UI compatibility 87 | local cake_egress=$(echo "$cake_egress_stats" | jq -c '.[0] // {}' 2>/dev/null || echo "{}") 88 | local cake_ingress=$(echo "$cake_ingress_stats" | jq -c '.[0] // {}' 2>/dev/null || echo "{}") 89 | 90 | # Create final JSON output using jq to ensure proper escaping 91 | result=$(jq -n \ 92 | --arg rq "$root_qdisc" \ 93 | --arg wi "$wan_interface" \ 94 | --arg ii "$ifb_interface" \ 95 | --arg pqi "$priority_queue_ingress" \ 96 | --arg pqe "$priority_queue_egress" \ 97 | --argjson fs "$filtered_stats" \ 98 | --argjson ce "$cake_egress" \ 99 | --argjson ci "$cake_ingress" \ 100 | '{ 101 | root_qdisc: $rq, 102 | wan_interface: $wi, 103 | ifb_interface: $ii, 104 | priority_queue_ingress: $pqi, 105 | priority_queue_egress: $pqe, 106 | qdisc_stats: $fs, 107 | cake_egress: $ce, 108 | cake_ingress: $ci 109 | }' 2>/dev/null) 110 | elif [ "$root_qdisc" = "hfsc" ]; then 111 | # Extract HFSC root qdiscs and classes 112 | local hfsc_egress_qdisc 113 | hfsc_egress_qdisc=$(get_tc_json tc -s -j qdisc show dev "$wan_interface" | jq -c "[.[] | select(.kind == \"hfsc\")]" 2>/dev/null || echo "[]") 114 | debug_log "HFSC egress qdisc: $hfsc_egress_qdisc" 115 | 116 | local hfsc_egress_classes 117 | hfsc_egress_classes=$(get_tc_json tc -s -j class show dev "$wan_interface") 118 | debug_log "HFSC egress classes: $hfsc_egress_classes" 119 | 120 | # Process the output to ensure it's valid JSON 121 | hfsc_egress_classes=$(echo "$hfsc_egress_classes" | jq -c '.' 2>/dev/null || echo "[]") 122 | 123 | local hfsc_ingress_qdisc 124 | hfsc_ingress_qdisc=$(get_tc_json tc -s -j qdisc show dev "$ifb_interface" | jq -c "[.[] | select(.kind == \"hfsc\")]" 2>/dev/null || echo "[]") 125 | debug_log "HFSC ingress qdisc: $hfsc_ingress_qdisc" 126 | 127 | local hfsc_ingress_classes 128 | hfsc_ingress_classes=$(get_tc_json tc -s -j class show dev "$ifb_interface") 129 | debug_log "HFSC ingress classes: $hfsc_ingress_classes" 130 | 131 | # Process the output to ensure it's valid JSON 132 | hfsc_ingress_classes=$(echo "$hfsc_ingress_classes" | jq -c '.' 2>/dev/null || echo "[]") 133 | 134 | # Get leaf qdisc statistics 135 | local egress_leaf_qdiscs 136 | egress_leaf_qdiscs=$(get_tc_json tc -s -j qdisc show dev "$wan_interface") 137 | debug_log "Egress leaf qdiscs: $egress_leaf_qdiscs" 138 | 139 | # Process the output to ensure it's valid JSON and filter non-HFSC qdiscs 140 | egress_leaf_qdiscs=$(echo "$egress_leaf_qdiscs" | jq -c '[.[] | select(.kind != "hfsc" and .parent != null)]' 2>/dev/null || echo "[]") 141 | 142 | local ingress_leaf_qdiscs 143 | ingress_leaf_qdiscs=$(get_tc_json tc -s -j qdisc show dev "$ifb_interface") 144 | debug_log "Ingress leaf qdiscs: $ingress_leaf_qdiscs" 145 | 146 | # Process the output to ensure it's valid JSON and filter non-HFSC qdiscs 147 | ingress_leaf_qdiscs=$(echo "$ingress_leaf_qdiscs" | jq -c '[.[] | select(.kind != "hfsc" and .parent != null)]' 2>/dev/null || echo "[]") 148 | 149 | # Get game qdisc type 150 | local gameqdisc 151 | gameqdisc=$(uci -q get qosmate.hfsc.gameqdisc || echo "pfifo") 152 | 153 | # Extract the main HFSC qdisc objects for UI compatibility 154 | local hfsc_egress=$(echo "$hfsc_egress_qdisc" | jq -c '.[0] // {}' 2>/dev/null || echo "{}") 155 | local hfsc_ingress=$(echo "$hfsc_ingress_qdisc" | jq -c '.[0] // {}' 2>/dev/null || echo "{}") 156 | 157 | # Create final JSON output using jq to ensure proper escaping 158 | result=$(jq -n \ 159 | --arg rq "$root_qdisc" \ 160 | --arg wi "$wan_interface" \ 161 | --arg ii "$ifb_interface" \ 162 | --arg gq "$gameqdisc" \ 163 | --argjson fs "$filtered_stats" \ 164 | --argjson he "$hfsc_egress" \ 165 | --argjson hi "$hfsc_ingress" \ 166 | --argjson hec "$hfsc_egress_classes" \ 167 | --argjson hic "$hfsc_ingress_classes" \ 168 | --argjson elq "$egress_leaf_qdiscs" \ 169 | --argjson ilq "$ingress_leaf_qdiscs" \ 170 | '{ 171 | root_qdisc: $rq, 172 | wan_interface: $wi, 173 | ifb_interface: $ii, 174 | gameqdisc: $gq, 175 | qdisc_stats: $fs, 176 | hfsc_egress: $he, 177 | hfsc_ingress: $hi, 178 | hfsc_egress_classes: $hec, 179 | hfsc_ingress_classes: $hic, 180 | egress_leaf_qdiscs: $elq, 181 | ingress_leaf_qdiscs: $ilq 182 | }' 2>/dev/null) 183 | fi 184 | 185 | echo "$result" 186 | } 187 | 188 | # Function to get historical statistics 189 | get_historical_stats() { 190 | # Note: This is currently a placeholder function for future implementation 191 | # In the future, this could provide historical QoS statistics from a database or log files 192 | # Currently returns an empty JSON object as no history is being saved 193 | local history_file="/tmp/qosmate_stats_history.json" 194 | 195 | if [ -f "$history_file" ]; then 196 | cat "$history_file" 197 | else 198 | echo "{}" 199 | fi 200 | } 201 | 202 | # Function to get RRD data if available 203 | get_rrd_data() { 204 | # Note: This is currently a placeholder function for future implementation 205 | # In the future, this could provide Round Robin Database data for generating time-series charts 206 | # Currently only checks if the RRD directory exists but doesn't actually process any data 207 | # Check if RRD data is available for QoS 208 | if [ -d "/tmp/rrd" ]; then 209 | echo "{\"rrd_available\": true}" 210 | else 211 | echo "{\"rrd_available\": false}" 212 | fi 213 | } 214 | 215 | # Function to handle the call command 216 | handle_call() { 217 | # Process input JSON 218 | local input_json 219 | input_json=$(cat) 220 | debug_log "Input JSON: $input_json" 221 | 222 | # Extract method directly from the JSON 223 | local method 224 | method=$(echo "$input_json" | jsonfilter -e '@.method') 225 | debug_log "Extracted method: $method" 226 | 227 | # Handle empty method case 228 | if [ -z "$method" ]; then 229 | # Default to getStats if no method is specified 230 | method="getStats" 231 | debug_log "Using default method: $method" 232 | fi 233 | 234 | # Process based on method 235 | case "$method" in 236 | getStats) 237 | get_stats 238 | ;; 239 | getHistoricalStats) 240 | get_historical_stats 241 | ;; 242 | getRrdData) 243 | get_rrd_data 244 | ;; 245 | *) 246 | debug_log "Unknown method: $method" 247 | echo '{"error": "Method not found"}' 248 | ;; 249 | esac 250 | } 251 | 252 | # Main function to handle RPC calls 253 | case "$1" in 254 | list) 255 | # List available methods 256 | echo '{"getStats": {}, "getHistoricalStats": {}, "getRrdData": {}}' 257 | ;; 258 | call) 259 | handle_call 260 | ;; 261 | *) 262 | echo '{"error": "Invalid call"}' 263 | ;; 264 | esac 265 | -------------------------------------------------------------------------------- /root/usr/share/luci/menu.d/luci-app-qosmate.json: -------------------------------------------------------------------------------- 1 | { 2 | "admin/network/qosmate": { 3 | "title": "QoSmate", 4 | "order": 70, 5 | "action": { 6 | "type": "firstchild" 7 | }, 8 | "depends": { 9 | "acl": [ "luci-app-qosmate" ], 10 | "uci": { "qosmate": true } 11 | } 12 | }, 13 | "admin/network/qosmate/settings": { 14 | "title": "Settings", 15 | "order": 10, 16 | "action": { 17 | "type": "view", 18 | "path": "qosmate/settings" 19 | } 20 | }, 21 | "admin/network/qosmate/hfsc": { 22 | "title": "HFSC", 23 | "order": 20, 24 | "action": { 25 | "type": "view", 26 | "path": "qosmate/hfsc" 27 | } 28 | }, 29 | "admin/network/qosmate/cake": { 30 | "title": "CAKE", 31 | "order": 30, 32 | "action": { 33 | "type": "view", 34 | "path": "qosmate/cake" 35 | } 36 | }, 37 | "admin/network/qosmate/advanced": { 38 | "title": "Advanced", 39 | "order": 40, 40 | "action": { 41 | "type": "view", 42 | "path": "qosmate/advanced" 43 | } 44 | }, 45 | "admin/network/qosmate/rules": { 46 | "title": "Rules", 47 | "order": 50, 48 | "action": { 49 | "type": "view", 50 | "path": "qosmate/rules" 51 | } 52 | }, 53 | "admin/network/qosmate/ipsets": { 54 | "title": "IP Sets", 55 | "order": 45, 56 | "action": { 57 | "type": "view", 58 | "path": "qosmate/ipsets" 59 | } 60 | }, 61 | "admin/network/qosmate/custom_rules": { 62 | "title": "Custom Rules", 63 | "order": 60, 64 | "action": { 65 | "type": "view", 66 | "path": "qosmate/custom_rules" 67 | } 68 | }, 69 | "admin/network/qosmate/connections": { 70 | "title": "Connections", 71 | "order": 70, 72 | "action": { 73 | "type": "view", 74 | "path": "qosmate/connections" 75 | } 76 | }, 77 | "admin/network/qosmate/statistics": { 78 | "title": "Statistics", 79 | "order": 80, 80 | "action": { 81 | "type": "view", 82 | "path": "qosmate/statistics" 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /root/usr/share/rpcd/acl.d/luci-app-qosmate.json: -------------------------------------------------------------------------------- 1 | { 2 | "luci-app-qosmate": { 3 | "description": "Grant access to QoSmate configuration", 4 | "read": { 5 | "ubus": { 6 | "luci.qosmate": [ "getConntrackDSCP" ], 7 | "luci.qosmate_stats": [ "getStats", "getHistoricalStats", "getRrdData" ], 8 | "luci": [ "getInitList", "setInitAction", "getInitActionStatus", "exec" ] 9 | }, 10 | "uci": [ "qosmate" ], 11 | "file": { 12 | "/etc/qosmate.sh": [ "read" ], 13 | "/etc/init.d/qosmate": [ "read", "exec" ], 14 | "/etc/hotplug.d/iface/13-qosmateHotplug": [ "read" ], 15 | "/etc/config/qosmate": [ "read" ], 16 | "/tmp/qosmate_auto_setup_output.txt": [ "read" ], 17 | "/etc/qosmate.d/custom_rules.nft": [ "read" ], 18 | "/tmp/qosmate_custom_rules_validation.txt": [ "read" ], 19 | "/tmp/qosmate_stats_history.json": [ "read" ] 20 | } 21 | }, 22 | "write": { 23 | "ubus": { 24 | "luci": [ "setInitAction", "exec" ] 25 | }, 26 | "uci": [ "qosmate" ], 27 | "file": { 28 | "/etc/qosmate.sh": [ "write" ], 29 | "/etc/init.d/qosmate": [ "write" ], 30 | "/etc/hotplug.d/iface/13-qosmateHotplug": [ "write" ], 31 | "/etc/qosmate.d/custom_rules.nft": [ "write" ] 32 | } 33 | } 34 | } 35 | } 36 | --------------------------------------------------------------------------------