edit.html 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <div class="row tile">
  2. <div class="col-md-12 col-md-auto">
  3. <div class="ibox float-e-margins">
  4. <h3 class="ibox-title">编辑</h3>
  5. <div class="ibox-content">
  6. <form class="form-horizontal">
  7. <input type="hidden" name="id" value="{{.t.Id}}">
  8. <div class="form-group">
  9. <label class="col-sm-2 control-label" langtag="info-mode">类型 </label>
  10. <div class="col-sm-10">
  11. <select class="form-control" name="type" id="type">
  12. <option {{if eq "tcp" .t.Mode}}selected{{end}} value="tcp">tcp</option>
  13. <option {{if eq "udp" .t.Mode}}selected{{end}} value="udp">udp</option>
  14. <option {{if eq "socks5" .t.Mode}}selected{{end}} value="socks5">socks5
  15. </option>
  16. <option {{if eq "httpProxy" .t.Mode}}selected{{end}} value="httpProxy">http</option>
  17. <option {{if eq "secret" .t.Mode}}selected{{end}} value="secret">secret</option>
  18. <option {{if eq "p2p" .t.Mode}}selected{{end}} value="p2p">p2p</option>
  19. <option {{if eq "file" .t.Mode}}selected{{end}} value="file">file</option>
  20. </select>
  21. </div>
  22. </div>
  23. <div class="form-group">
  24. <label class="col-sm-2 control-label" langtag="info-remark">备注</label>
  25. <div class="col-sm-10">
  26. <input value="{{.t.Remark}}" class="form-control" type="text" name="remark"
  27. placeholder="empty means to be unrestricted">
  28. </div>
  29. </div>
  30. {{if eq true .allow_multi_ip}}
  31. <div class="form-group" id="server_ip">
  32. <label class="col-sm-2 control-label" langtag="info-server-ip">服务端ip</label>
  33. <div class="col-sm-10">
  34. <input class="form-control" type="text" value="{{.t.ServerIp}}" name="server_ip"
  35. placeholder="such as 0.0.0.0">
  36. </div>
  37. </div>
  38. {{end}}
  39. <div class="form-group" id="port">
  40. <label class="col-sm-2 control-label" langtag="info-server-port">服务端端口</label>
  41. <div class="col-sm-10">
  42. <input value="{{.t.Port}}" class="form-control" type="text" name="port"
  43. placeholder="such as 8024">
  44. </div>
  45. </div>
  46. {{if eq true .allow_local_proxy}}
  47. <div class="form-group" id="local_proxy">
  48. <label class="control-label col-sm-2" langtag="info-local-proxy">是否代理为服务端本地</label>
  49. <div class="col-sm-10">
  50. <select class="form-control" name="local_proxy">
  51. <option {{if eq false .t.Target.LocalProxy}}selected{{end}} value="0">no</option>
  52. <option {{if eq true .t.Target.LocalProxy}}selected{{end}} value="1">yes</option>
  53. </select>
  54. </div>
  55. </div>
  56. {{end}}
  57. <div class="form-group" id="target">
  58. <label class="col-sm-2 control-label" langtag="info-target">内网目标(ip:端口)</label>
  59. <div class="col-sm-10">
  60. <textarea class="form-control" name="target" rows="4" placeholder="10.1.50.203:22
  61. 10.1.50.202:22">{{.t.Target.TargetStr}}</textarea>
  62. <span class="help-block m-b-none">can only fill in ports if it is local machine proxy, only tcp supports load balancing
  63. </span></div>
  64. </div>
  65. <div class="form-group" id="client_id">
  66. <label class="col-sm-2 control-label" langtag="info-client-id">客户端id</label>
  67. <div class="col-sm-10">
  68. <input value="{{.t.Client.Id}}" value="{{.client_id}}" class="form-control" type="text"
  69. name="client_id"
  70. placeholder="id of client">
  71. </div>
  72. </div>
  73. <div class="form-group" id="local_path">
  74. <label class="col-sm-2 control-label" langtag="info-local-path">本地路径</label>
  75. <div class="col-sm-10">
  76. <input value="{{.t.LocalPath}}" class="form-control" type="text" name="local_path"
  77. placeholder="such as /tmp">
  78. </div>
  79. </div>
  80. <div class="form-group" id="strip_pre">
  81. <label class="col-sm-2 control-label" langtag="info-strip-pre">访问前缀</label>
  82. <div class="col-sm-10">
  83. <input value="{{.t.StripPre}}" class="form-control" type="text" name="strip_pre"
  84. placeholder="such as static">
  85. </div>
  86. </div>
  87. <div class="form-group" id="password">
  88. <label class="col-sm-2 control-label" langtag="info-unique-vkey">唯一验证密钥</label>
  89. <div class="col-sm-10">
  90. <input value="{{.t.Password}}" class="form-control" type="text" name="password"
  91. placeholder="unique identification key">
  92. <span class="help-block m-b-none">when p2p or secret</span>
  93. </div>
  94. </div>
  95. <div class="hr-line-dashed"></div>
  96. <div class="form-group">
  97. <div class="col-sm-4 col-sm-offset-2">
  98. <button class="btn btn-success" href="#" id="add"><i
  99. class="fa fa-fw fa-lg fa-eye"></i><span langtag="info-save">保存</span>
  100. </button>
  101. </div>
  102. </div>
  103. </form>
  104. </div>
  105. </div>
  106. </div>
  107. </div>
  108. <script>
  109. var arr = []
  110. arr["all"] = ["type", "port", "compress", "u", "p", "target", "password", "local_path", "strip_pre", "local_proxy"]
  111. arr["tcp"] = ["type", "port", "target", "u", "p", "compress", "local_proxy"]
  112. arr["udp"] = ["type", "port", "target", "compress", "local_proxy"]
  113. arr["socks5"] = ["type", "port", "compress", "u", "p"]
  114. arr["httpProxy"] = ["type", "port", "compress", "u", "p"]
  115. arr["secret"] = ["type", "target", "compress", "u", "p", "password"]
  116. arr["p2p"] = ["type", "target", "password"]
  117. arr["file"] = ["type", "port", "local_path", "strip_pre"]
  118. arrClientHide = ["compress", "u", "p", "crypt", "mux"]
  119. function resetForm() {
  120. for (var i = 0; i < arr["all"].length; i++) {
  121. $("#" + arr["all"][i]).css("display", "none")
  122. }
  123. o = $("#type option:selected").val()
  124. for (var i = 0; i < arr[o].length; i++) {
  125. $("#" + arr[o][i]).css("display", "block")
  126. }
  127. }
  128. function resetClientCnf() {
  129. for (var i = 0; i < arrClientHide.length; i++) {
  130. $("#" + arrClientHide[i]).css("display", "block")
  131. }
  132. op = $("#use_client option:selected").val()
  133. if (op == 1) {
  134. for (var i = 0; i < arrClientHide.length; i++) {
  135. $("#" + arrClientHide[i]).css("display", "none")
  136. }
  137. }
  138. }
  139. $(function () {
  140. resetForm()
  141. resetClientCnf()
  142. $("#type").on("change", function () {
  143. resetForm()
  144. resetClientCnf()
  145. })
  146. $("#use_client").on("change", function () {
  147. resetForm()
  148. resetClientCnf()
  149. })
  150. $("#add").on("click", function () {
  151. $.ajax({
  152. type: "POST",
  153. url: "{{.web_base_url}}/index/edit",
  154. data: $("form").serializeArray(),
  155. success: function (res) {
  156. alert(res.msg)
  157. if (res.status) {
  158. history.back(-1)
  159. }
  160. }
  161. })
  162. })
  163. })
  164. </script>