add_firewall_ipset.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <!-- Begin toolbar -->
  2. <div class="toolbar">
  3. <div class="toolbar-inner">
  4. <div class="toolbar-buttons">
  5. <a class="button button-secondary" id="btn-back" href="/list/firewall/ipset/">
  6. <i class="fas fa-arrow-left icon-blue"></i><?= _("Back") ?>
  7. </a>
  8. </div>
  9. <div class="toolbar-buttons">
  10. <button type="submit" class="button" form="vstobjects">
  11. <i class="fas fa-floppy-disk icon-purple"></i><?= _("Save") ?>
  12. </button>
  13. </div>
  14. </div>
  15. </div>
  16. <!-- End toolbar -->
  17. <div class="container animate__animated animate__fadeIn">
  18. <form id="vstobjects" name="v_add_ipset" method="post">
  19. <input type="hidden" name="token" value="<?= $_SESSION["token"] ?>">
  20. <input type="hidden" name="ok" value="Add">
  21. <div class="form-container">
  22. <h1 class="form-title"><?= _("Adding Firewall Ipset List") ?></h1>
  23. <?php show_alert_message($_SESSION); ?>
  24. <div class="u-mb10">
  25. <label for="v_ipname" class="form-label"><?= _("Ip List Name") ?></label>
  26. <input type="text" class="form-control" name="v_ipname" id="v_ipname" maxlength="255" value="<?= htmlentities(trim($v_ipname, "'")) ?>">
  27. </div>
  28. <div class="u-mb10">
  29. <label for="v_datasource" class="form-label">
  30. <?= _("Data Source") ?> <span class="optional">(<?= _("url, script or file") ?>)</span>
  31. </label>
  32. <div class="u-pos-relative">
  33. <select class="form-select" tabindex="-1" id="datasource_list" onchange="this.nextElementSibling.value=this.value">
  34. <option value="">clear</option>
  35. </select>
  36. <input type="text" class="form-control list-editor" name="v_datasource" id="v_datasource" maxlength="255" value="<?= htmlentities(trim($v_datasource, "'")) ?>">
  37. </div>
  38. </div>
  39. <div class="u-mb10">
  40. <label for="v_ipver" class="form-label"><?= _("Ip Version") ?></label>
  41. <select class="form-select" name="v_ipver" id="v_ipver">
  42. <option value="v4" <?php if ((!empty($v_ipver)) && ( $v_ipver == "'v4'" )) echo 'selected'?>><?= _("ip v4") ?></option>
  43. <option value="v6" <?php if ((!empty($v_ipver)) && ( $v_ipver == "'v6'" )) echo 'selected'?>><?= _("ip v6") ?></option>
  44. </select>
  45. </div>
  46. <div class="u-mb10">
  47. <label for="v_autoupdate" class="form-label"><?= _("Autoupdate") ?></label>
  48. <select class="form-select" name="v_autoupdate" id="v_autoupdate">
  49. <option value="yes" <?php if ((!empty($v_autoupdate)) && ( $v_autoupdate == "'yes'" )) echo 'selected'?>><?= _("yes") ?></option>
  50. <option value="no" <?php if ((!empty($v_autoupdate)) && ( $v_autoupdate == "'no'" )) echo 'selected'?>><?= _("no") ?></option>
  51. </select>
  52. </div>
  53. </div>
  54. </form>
  55. </div>
  56. <script>
  57. var country_iplists = [
  58. <?php
  59. $country = array('ca' => 'Canada', 'cn' => 'China', 'fr' => 'French', 'de' => 'Germany', 'in' => 'India', 'nl' => 'Netherlands', 'ro' => 'Romania', 'ru' => 'Russia', 'es' => 'Spain', 'ch' => 'Switzerland', 'tr' => 'Turkey', 'ua' => 'Ukraine', 'gb' => 'United Kingdom', 'us' => 'United States');
  60. foreach($country as $iso =>$name){
  61. echo '{name: "[IPv4] Country - '.$name.'", source:"https://raw.githubusercontent.com/ipverse/rir-ip/master/country/'.$iso.'/ipv4-aggregated.txt"},'."\n";
  62. }
  63. ?>
  64. // Define IPv6 country lists
  65. /*
  66. <?php
  67. foreach($country as $iso =>$name){
  68. echo '{name: "[IPv6] Country - '.$name.'", source:"https://raw.githubusercontent.com/ipverse/rir-ip/master/country/'.$iso.'/ipv6-aggregated.txt"},'."\n";
  69. }
  70. ?>
  71. */
  72. ];
  73. var blacklist_iplists = [
  74. { name: "[IPv4] Block Malicious IPs", source: "script:/usr/local/hestia/install/deb/firewall/ipset/blacklist.sh" },
  75. /*
  76. {name: "[IPv6] Block Malicious IPs", source:"script:/usr/local/hestia/install/deb/firewall/ipset/blacklist.ipv6.sh"},
  77. */
  78. ];
  79. country_iplists.sort(function (a, b) {
  80. return a.name > b.name;
  81. });
  82. blacklist_iplists.sort(function (a, b) {
  83. return a.name > b.name;
  84. });
  85. $(function () {
  86. var targetElement = document.getElementById('datasource_list');
  87. // Blacklist
  88. var newEl = document.createElement("option");
  89. newEl.text = "<?= _("BLACKLIST") ?>";
  90. newEl.disabled = true;
  91. targetElement.appendChild(newEl);
  92. blacklist_iplists.forEach(iplist => {
  93. var newEl = document.createElement("option");
  94. newEl.text = iplist.name;
  95. newEl.value = iplist.source;
  96. targetElement.appendChild(newEl);
  97. });
  98. // IPVERSE
  99. var newEl = document.createElement("option");
  100. newEl.text = "<?= _("IPVERSE") ?>";
  101. newEl.disabled = true;
  102. targetElement.appendChild(newEl);
  103. country_iplists.forEach(iplist => {
  104. var newEl = document.createElement("option");
  105. newEl.text = iplist.name;
  106. newEl.value = iplist.source;
  107. targetElement.appendChild(newEl);
  108. });
  109. });
  110. </script>