edit.html 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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.Client.Id}}" 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.Config.Compress}}selected{{end}} value="">不压缩</option>
  48. <option {{if eq "snappy" .t.Config.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.Config.Crypt}}selected{{end}} value="0">不加密</option>
  55. <option {{if eq true .t.Config.Crypt}}selected{{end}} value="1">加密</option>
  56. </select>
  57. </div>
  58. <div class="form-group" id="u">
  59. <label class="control-label">验证用户名(仅socks5,web穿透支持)</label>
  60. <input class="form-control" value="{{.t.Config.U}}" type="text" name="u"
  61. placeholder="不填则无需验证">
  62. </div>
  63. <div class="form-group" id="p">
  64. <label class="control-label">验证密码(仅socks5,web穿透支持)</label>
  65. <input class="form-control" value="{{.t.Config.P}}" type="text" name="p"
  66. placeholder="不填则无需验证">
  67. </div>
  68. </form>
  69. </div>
  70. <div class="tile-footer">
  71. &nbsp;&nbsp;<button class="btn btn-success" href="#" id="add"><i
  72. class="fa fa-fw fa-lg fa-eye"></i>保存
  73. </button>
  74. </div>
  75. </div>
  76. </div>
  77. </div>
  78. </main>
  79. <script>
  80. var arr = []
  81. arr["all"] = ["type", "port", "compress", "u", "p", "target"]
  82. arr["tunnelServer"] = ["type", "port", "target", "u", "p", "compress"]
  83. arr["udpServer"] = ["type", "port", "target", "compress"]
  84. arr["socks5Server"] = ["type", "port", "compress", "u", "p"]
  85. arr["httpProxyServer"] = ["type", "port", "compress", "u", "p"]
  86. arrClientHide = ["compress", "u", "p", "crypt", "mux"]
  87. function resetForm() {
  88. for (var i = 0; i < arr["all"].length; i++) {
  89. $("#" + arr["all"][i]).css("display", "none")
  90. }
  91. o = $("#type option:selected").val()
  92. for (var i = 0; i < arr[o].length; i++) {
  93. $("#" + arr[o][i]).css("display", "block")
  94. }
  95. }
  96. function resetClientCnf() {
  97. for (var i = 0; i < arrClientHide.length; i++) {
  98. $("#" + arrClientHide[i]).css("display", "block")
  99. }
  100. op = $("#use_client option:selected").val()
  101. if (op == 1) {
  102. for (var i = 0; i < arrClientHide.length; i++) {
  103. $("#" + arrClientHide[i]).css("display", "none")
  104. }
  105. }
  106. }
  107. $(function () {
  108. resetForm()
  109. resetClientCnf()
  110. $("#type").on("change", function () {
  111. resetForm()
  112. resetClientCnf()
  113. })
  114. $("#use_client").on("change", function () {
  115. resetForm()
  116. resetClientCnf()
  117. })
  118. $("#add").on("click", function () {
  119. $.ajax({
  120. type: "POST",
  121. url: "/index/edit",
  122. data: $("form").serializeArray(),
  123. success: function (res) {
  124. alert(res.msg)
  125. if (res.status) {
  126. history.back(-1)
  127. }
  128. }
  129. })
  130. })
  131. })
  132. </script>