edit.html 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <div class="row tile">
  2. <div class="col-md-6 col-md-auto">
  3. <div>
  4. <h3 class="tile-title">添加</h3>
  5. <div class="tile-body">
  6. <form>
  7. <input type="hidden" name="id" value="{{.t.Id}}">
  8. <div class="form-group">
  9. <label class="control-label">模式</label>
  10. <select class="form-control" name="type" id="type">
  11. <option {{if eq "tunnelServer" .t.Mode}}selected{{end}} value="tunnelServer">tcp隧道</option>
  12. <option {{if eq "udpServer" .t.Mode}}selected{{end}} value="udpServer">udp隧道</option>
  13. <option {{if eq "socks5Server" .t.Mode}}selected{{end}} value="socks5Server">socks5代理
  14. </option>
  15. <option {{if eq "httpProxyServer" .t.Mode}}selected{{end}} value="httpProxyServer">http代理
  16. </select>
  17. </div>
  18. <div class="form-group">
  19. <label class="control-label">备注</label>
  20. <input class="form-control" value="{{.t.Remark}}" type="text" name="remark" placeholder="备注">
  21. </div>
  22. <div class="form-group" id="port">
  23. <label class="control-label">监听的端口</label>
  24. <input class="form-control" value="{{.t.TcpPort}}" type="text" name="port"
  25. placeholder="公网服务器对外访问端口,例如8024">
  26. </div>
  27. <div class="form-group" id="target">
  28. <label class="control-label">内网目标(仅tcp、udp隧道模式需填写)</label>
  29. <input class="form-control" value="{{.t.Target}}" type="text" name="target"
  30. placeholder="内网隧道目标,例如10.1.50.203:22">
  31. </div>
  32. <div class="form-group" id="client_id">
  33. <label class="control-label">客户端ID</label>
  34. <input class="form-control" value="{{.t.ClientId}}" type="text" name="client_id"
  35. placeholder="客户端id">
  36. </div>
  37. <div class="form-group" id="use_client">
  38. <label class="control-label">是否使用客户端配置</label>
  39. <select class="form-control" name="use_client">
  40. <option {{if eq false .t.UseClientCnf}}selected{{end}} value="0">否</option>
  41. <option {{if eq true .t.UseClientCnf}}selected{{end}} value="1">是</option>
  42. </select>
  43. </div>
  44. <div class="form-group" id="compress">
  45. <label class="control-label">数据压缩方式(所有模式均支持)</label>
  46. <select class="form-control" name="compress">
  47. <option {{if eq "" .t.Compress}}selected{{end}} value="">不压缩</option>
  48. <option {{if eq "snappy" .t.Compress}}selected{{end}} value="snappy">snappy压缩</option>
  49. </select>
  50. </div>
  51. <div class="form-group" id="crypt">
  52. <label class="control-label">是否加密传输(所有模式均支持)</label>
  53. <select class="form-control" name="crypt">
  54. <option {{if eq false .t.Crypt}}selected{{end}} value="0">不加密</option>
  55. <option {{if eq true .t.Crypt}}selected{{end}} value="1">加密</option>
  56. </select>
  57. </div>
  58. <div class="form-group" id="mux">
  59. <label class="control-label">是否启用TCP复用(所有模式均支持)</label>
  60. <select class="form-control" name="mux">
  61. <option {{if eq false .t.Mux}}selected{{end}} value="0">不启用</option>
  62. <option {{if eq true .t.Mux}}selected{{end}} value="1">启用</option>
  63. </select>
  64. </div>
  65. <div class="form-group" id="u">
  66. <label class="control-label">验证用户名(仅socks5,web穿透支持)</label>
  67. <input class="form-control" value="{{.t.U}}" type="text" name="u"
  68. placeholder="不填则无需验证">
  69. </div>
  70. <div class="form-group" id="p">
  71. <label class="control-label">验证密码(仅socks5,web穿透支持)</label>
  72. <input class="form-control" value="{{.t.P}}" type="text" name="p"
  73. placeholder="不填则无需验证">
  74. </div>
  75. </form>
  76. </div>
  77. <div class="tile-footer">
  78. &nbsp;&nbsp;<button class="btn btn-success" href="#" id="add"><i
  79. class="fa fa-fw fa-lg fa-eye"></i>保存
  80. </button>
  81. </div>
  82. </div>
  83. </div>
  84. </div>
  85. </main>
  86. <script>
  87. var arr = []
  88. arr["all"] = ["type", "port", "compress", "u", "p", "target"]
  89. arr["tunnelServer"] = ["type", "port", "target", "u", "p", "compress"]
  90. arr["udpServer"] = ["type", "port", "target", "compress"]
  91. arr["socks5Server"] = ["type", "port", "compress", "u", "p"]
  92. arr["httpProxyServer"] = ["type", "port", "compress", "u", "p"]
  93. arrClientHide = ["compress", "u", "p", "crypt", "mux"]
  94. function resetForm() {
  95. for (var i = 0; i < arr["all"].length; i++) {
  96. $("#" + arr["all"][i]).css("display", "none")
  97. }
  98. o = $("#type option:selected").val()
  99. for (var i = 0; i < arr[o].length; i++) {
  100. $("#" + arr[o][i]).css("display", "block")
  101. }
  102. }
  103. function resetClientCnf() {
  104. for (var i = 0; i < arrClientHide.length; i++) {
  105. $("#" + arrClientHide[i]).css("display", "block")
  106. }
  107. op = $("#use_client option:selected").val()
  108. if (op == 1) {
  109. for (var i = 0; i < arrClientHide.length; i++) {
  110. $("#" + arrClientHide[i]).css("display", "none")
  111. }
  112. }
  113. }
  114. $(function () {
  115. resetForm()
  116. resetClientCnf()
  117. $("#type").on("change", function () {
  118. resetForm()
  119. resetClientCnf()
  120. })
  121. $("#use_client").on("change", function () {
  122. resetForm()
  123. resetClientCnf()
  124. })
  125. $("#add").on("click", function () {
  126. $.ajax({
  127. type: "POST",
  128. url: "/index/edit",
  129. data: $("form").serializeArray(),
  130. success: function (res) {
  131. alert(res.msg)
  132. if (res.status) {
  133. history.back(-1)
  134. }
  135. }
  136. })
  137. })
  138. })
  139. </script>