nodeInfo.blade.php 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706
  1. @extends('admin.layouts')
  2. @section('css')
  3. <link href="/assets/global/vendor/bootstrap-select/bootstrap-select.min.css" type="text/css" rel="stylesheet">
  4. <link href="/assets/global/vendor/switchery/switchery.min.css" type="text/css" rel="stylesheet">
  5. <style type="text/css">
  6. .hidden {
  7. display: none
  8. }
  9. </style>
  10. @endsection
  11. @section('content')
  12. <div class="page-content container-fluid">
  13. <div class="panel">
  14. <div class="panel-heading">
  15. <h2 class="panel-title">@isset($node) 编辑节点 @else 添加节点 @endisset</h2>
  16. </div>
  17. <div class="alert alert-info" role="alert">
  18. <button class="close" data-dismiss="alert" aria-label="Close">
  19. <span aria-hidden="true">&times;</span>
  20. <span class="sr-only">{{trans('home.close')}}</span>
  21. </button>
  22. <strong>注意:</strong> 添加节点后自动生成的<code>ID</code>,即为该节点部署ShadowsocksR Python版后端时<code>usermysql.json</code>中的<code>node_id</code>的值,同时也是部署V2Ray后端时的<code>nodeId</code>的值;
  23. </div>
  24. <div class="panel-body">
  25. <form action=@isset($node){{url('/node/edit')}} @else {{url('/node/add')}} @endisset method="post" enctype="multipart/form-data" class="form-horizontal" onsubmit="return Submit()">
  26. <div class="row">
  27. <div class="col-lg-6">
  28. <div class="example-wrap">
  29. <h4 class="example-title">基础信息</h4>
  30. <div class="example">
  31. <div class="form-group row">
  32. <label for="is_ddns" class="col-md-3 col-form-label">DDNS</label>
  33. <div class="col-md-9">
  34. <input type="checkbox" id="is_ddns" name="is_ddns" data-plugin="switchery" onchange="switchSetting('is_ddns')">
  35. </div>
  36. <div class="text-help offset-md-3">
  37. 动态IP节点需要<a href="https://github.com/NewFuture/DDNS" target="_blank">配置DDNS</a>,对此类型节点,节点阻断功能会通过域名进行检测
  38. </div>
  39. </div>
  40. <div class="form-group row">
  41. <label for="name" class="col-md-3 col-form-label"> 节点名称 </label>
  42. <input type="text" class="form-control col-md-4" name="name" id="name" required>
  43. </div>
  44. <div class="form-group row">
  45. <label for="server" class="col-md-3 col-form-label"> 域名 </label>
  46. <input type="text" class="form-control col-md-4" name="server" id="server" placeholder="服务器域名地址,填则优先取域名地址">
  47. <span class="text-help offset-md-3">如果开启Namesilo且域名是Namesilo上购买的,则会强制更新域名的DNS记录为本节点IP,如果其他节点绑定了该域名则会清空其域名信息</span>
  48. </div>
  49. <div class="form-group row">
  50. <label for="ip" class="col-md-3 col-form-label"> IPv4地址 </label>
  51. <input type="text" class="form-control col-md-4" name="ip" id="ip"
  52. placeholder="服务器IPv4地址" required>
  53. </div>
  54. <div class="form-group row">
  55. <label for="ipv6" class="col-md-3 col-form-label"> IPv6地址 </label>
  56. <input type="text" class="form-control col-md-4" name="ipv6" id="ipv6"
  57. placeholder="服务器IPv6地址,填写则用户可见,域名无效">
  58. </div>
  59. <div class="form-group row">
  60. <label for="push_port" class="col-md-3 col-form-label"> 消息推送端口 </label>
  61. <input type="number" class="form-control col-md-4" name="push_port" value="0" id="push_port">
  62. <span class="text-help offset-md-3">必填且防火墙需放行,否则将导致消息推送异常</span>
  63. </div>
  64. <div class="form-group row">
  65. <label for="traffic_rate" class="col-md-3 col-form-label"> 流量比例 </label>
  66. <input type="number" class="form-control col-md-4" name="traffic_rate"
  67. value="1.0" id="traffic_rate" step="0.01" required>
  68. <div class="text-help offset-md-3"> 举例:0.1用100M结算10M,5用100M结算500M</div>
  69. </div>
  70. <div class="form-group row">
  71. <label for="level" class="col-md-3 col-form-label">等级</label>
  72. <select data-plugin="selectpicker" data-style="btn-outline btn-primary" class="col-md-5 form-control show-tick" id="level" name="level">
  73. @foreach($levelList as $level)
  74. <option value="{{$level->level}}">{{$level->name}}</option>
  75. @endforeach
  76. </select>
  77. <div class="text-help offset-md-3"> 等级:0-无等级,全部可见</div>
  78. </div>
  79. <div class="form-group row">
  80. <label for="speed_limit" class="col-md-3 col-form-label">节点限速</label>
  81. <div class="col-md-4 input-group p-0">
  82. <input type="number" class="form-control" id="speed_limit" name="speed_limit" value="1000" required>
  83. <span class="input-group-text">Mbps</span>
  84. </div>
  85. </div>
  86. <div class="form-group row">
  87. <label for="client_limit" class="col-md-3 col-form-label">设备数限制</label>
  88. <input type="number" class="form-control col-md-4" id="client_limit" name="client_limit" value="1000" required>
  89. </div>
  90. <div class="form-group row">
  91. <label for="labels" class="col-md-3 col-form-label">标签</label>
  92. <select data-plugin="selectpicker" data-style="btn-outline btn-primary" class="col-md-5 form-control show-tick" id="labels" name="labels" multiple>
  93. @foreach($labelList as $label)
  94. <option value="{{$label->id}}">{{$label->name}}</option>
  95. @endforeach
  96. </select>
  97. </div>
  98. <div class="form-group row">
  99. <label for="country_code" class="col-md-3 col-form-label"> 国家/地区 </label>
  100. <select data-plugin="selectpicker" data-style="btn-outline btn-primary"
  101. class="col-md-5 form-control" name="country_code" id="country_code">
  102. <option value="un" selected hidden>请选择</option>
  103. @foreach($countryList as $country)
  104. <option value="{{$country->code}}">{{$country->code}}- {{$country->name}}</option>
  105. @endforeach
  106. </select>
  107. </div>
  108. <div class="form-group row">
  109. <label for="description" class="col-md-3 col-form-label"> 描述 </label>
  110. <input type="text" class="form-control col-md-6" name="description" id="description" placeholder="简单描述">
  111. </div>
  112. <div class="form-group row">
  113. <label for="sort" class="col-md-3 col-form-label">排序</label>
  114. <input type="text" class="form-control col-md-4" name="sort" id="sort" value="1" required/>
  115. <div class="text-help offset-md-3"> 排序值越大排越前 &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;</div>
  116. </div>
  117. <div class="form-group row">
  118. <label for="is_udp" class="col-md-3 col-form-label">UDP</label>
  119. <div class="col-md-9">
  120. <input type="checkbox" id="is_udp" name="is_udp" data-plugin="switchery">
  121. </div>
  122. </div>
  123. <div class="form-group row">
  124. <label for="status" class="col-md-3 col-form-label">状态</label>
  125. <div class="col-md-9">
  126. <input type="checkbox" id="status" name="status" data-plugin="switchery">
  127. </div>
  128. </div>
  129. </div>
  130. </div>
  131. </div>
  132. <div class="col-lg-6">
  133. <div class="example-wrap">
  134. <h4 class="example-title">扩展信息</h4>
  135. <div class="example">
  136. <div class="form-group row">
  137. <label for="type" class="col-md-3 col-form-label">类型</label>
  138. <ul class="col-md-9 list-unstyled list-inline">
  139. <li class="list-inline-item">
  140. <div class="radio-custom radio-primary">
  141. <input type="radio" id="shadowsocks" name="type" value="1" checked>
  142. <label for="shadowsocks">Shadowsocks(R)</label>
  143. </div>
  144. </li>
  145. <li class="list-inline-item">
  146. <div class="radio-custom radio-primary">
  147. <input type="radio" id="v2ray" name="type" value="2">
  148. <label for="v2ray">V2Ray</label>
  149. </div>
  150. </li>
  151. <li class="list-inline-item">
  152. <div class="radio-custom radio-primary">
  153. <input type="radio" id="trojan" name="type" value="3">
  154. <label for="trojan">Trojan</label>
  155. </div>
  156. </li>
  157. <li class="list-inline-item">
  158. <div class="radio-custom radio-primary">
  159. <input type="radio" id="vnet" name="type" value="4" checked>
  160. <label for="vnet">VNET</label>
  161. </div>
  162. </li>
  163. </ul>
  164. </div>
  165. <hr/>
  166. <!-- SS/SSR 设置部分 -->
  167. <div class="ssr-setting">
  168. <div class="form-group row">
  169. <label for="method" class="col-md-3 col-form-label">加密方式</label>
  170. <select data-plugin="selectpicker" data-style="btn-outline btn-primary" class="col-md-5 form-control" name="method" id="method">
  171. @foreach ($methodList as $method)
  172. <option value="{{$method->name}}" @if(!isset($node) && $method->is_default) selected @endif>{{$method->name}}</option>
  173. @endforeach
  174. </select>
  175. </div>
  176. <div class="form-group row">
  177. <label for="protocol" class="col-md-3 col-form-label">协议</label>
  178. <select data-plugin="selectpicker" data-style="btn-outline btn-primary" class="col-md-5 form-control" name="protocol" id="protocol">
  179. @foreach ($protocolList as $protocol)
  180. <option value="{{$protocol->name}}" @if(!isset($node) && $protocol->is_default) selected @endif>{{$protocol->name}}</option>
  181. @endforeach
  182. </select>
  183. </div>
  184. <div class="form-group row">
  185. <label for="protocol_param" class="col-md-3 col-form-label"> 协议参数 </label>
  186. <input type="text" class="form-control col-md-4" name="protocol_param" id="protocol_param">
  187. </div>
  188. <div class="form-group row">
  189. <label for="obfs" class="col-md-3 col-form-label">混淆</label>
  190. <select data-plugin="selectpicker" data-style="btn-outline btn-primary" class="col-md-5 form-control" name="obfs" id="obfs">
  191. @foreach ($obfsList as $obfs)
  192. <option value="{{$obfs->name}}" @if(!isset($node) && $obfs->is_default) selected @endif>{{$obfs->name}}</option>
  193. @endforeach
  194. </select>
  195. </div>
  196. <div class="form-group row obfs_param">
  197. <label for="obfs_param" class="col-md-3 col-form-label"> 混淆参数 </label>
  198. <textarea class="form-control col-md-8" rows="5" name="obfs_param" id="obfs_param" placeholder="混淆不为 [plain] 时可填入参数进行流量伪装;&#13;&#10;混淆为 [http_simple] 时,建议端口为 80;&#13;&#10;混淆为 [tls] 时,建议端口为 443;"></textarea>
  199. </div>
  200. <div class="form-group row">
  201. <label for="compatible" class="col-md-3 col-form-label">兼容SS</label>
  202. <div class="col-md-9">
  203. <input type="checkbox" id="compatible" name="compatible" data-plugin="switchery">
  204. </div>
  205. <div class="text-help offset-md-3">
  206. 如果兼容请在服务端配置协议和混淆时加上<span class="red-700">_compatible</span>
  207. </div>
  208. </div>
  209. <hr/>
  210. <div class="form-group row">
  211. <label for="single" class="col-md-3 col-form-label">单端口</label>
  212. <div class="col-md-9">
  213. <input type="checkbox" id="single" name="single" data-plugin="switchery" onchange="switchSetting('single')">
  214. </div>
  215. <div class="text-help offset-md-3">
  216. 如果启用请配置服务端的<span class="red-700"><a href="javascript:showTnc();">additional_ports</a></span>信息
  217. </div>
  218. </div>
  219. <div class="single-setting hidden">
  220. <div class="form-group row">
  221. <label for="single_port" class="col-md-3 col-form-label">[单] 端口</label>
  222. <input type="number" class="form-control col-md-4" name="port" value="443" id="single_port"/>
  223. <span class="text-help offset-md-3"> 推荐80或443,服务端需要配置 </span>
  224. <span class="text-help offset-md-3">
  225. 严格模式:用户的端口无法连接,只能通过以下指定的端口进行连接 (<a href="javascript:showPortsOnlyConfig();">如何配置</a>)</span>
  226. </div>
  227. <div class="form-group row">
  228. <label for="passwd" class="col-md-3 col-form-label">[单] 密码</label>
  229. <input type="text" class="form-control col-md-4" name="passwd" id="passwd" placeholder="password">
  230. </div>
  231. </div>
  232. </div>
  233. <!-- V2ray 设置部分 -->
  234. <div class="v2ray-setting hidden">
  235. <div class="form-group row">
  236. <label for="v2_alter_id" class="col-md-3 col-form-label">额外ID</label>
  237. <input type="text" class="form-control col-md-4" name="v2_alter_id" value="16" id="v2_alter_id" required/>
  238. </div>
  239. <div class="form-group row">
  240. <label for="v2ray_port" class="col-md-3 col-form-label">连接端口</label>
  241. <input type="number" class="form-control col-md-4" name="port" id="v2ray_port" value="443"/>
  242. </div>
  243. <div class="form-group row">
  244. <label for="v2_port" class="col-md-3 col-form-label">服务端口</label>
  245. <input type="number" class="form-control col-md-4" name="v2_port" id="v2_port" value="10053" required/>
  246. </div>
  247. <div class="form-group row">
  248. <label for="v2_method" class="col-md-3 col-form-label">加密方式</label>
  249. <select data-plugin="selectpicker" data-style="btn-outline btn-primary" class="col-md-5 form-control" id="v2_method">
  250. <option value="auto">auto</option>
  251. <option value="none">none</option>
  252. <option value="aes-128-gcm">aes-128-gcm</option>
  253. <option value="chacha20-poly1305">chacha20-poly1305</option>
  254. </select>
  255. <div class="text-help offset-md-3"> 使用WebSocket传输协议时不要使用none</div>
  256. </div>
  257. <div class="form-group row">
  258. <label for="v2_net" class="col-md-3 col-form-label">传输方式</label>
  259. <select data-plugin="selectpicker" data-style="btn-outline btn-primary" class="col-md-5 form-control" id="v2_net">
  260. <option value="tcp">TCP</option>
  261. <option value="kcp">mKCP</option>
  262. <option value="ws">WebSocket</option>
  263. <option value="http">HTTP/2</option>
  264. <option value="domainsocket">DomainSocket</option>
  265. <option value="quic">QUIC</option>
  266. </select>
  267. <div class="text-help offset-md-3"> 使用WebSocket传输协议时请启用TLS</div>
  268. </div>
  269. <div class="form-group row v2_type">
  270. <label for="v2_type" class="col-md-3 col-form-label">伪装类型</label>
  271. <select data-plugin="selectpicker" data-style="btn-outline btn-primary" class="col-md-5 form-control" id="v2_type">
  272. <option value="none">无伪装</option>
  273. <option value="http">HTTP数据流</option>
  274. <optgroup id="type_option" label="">
  275. <option value="srtp">视频通话数据 (SRTP)</option>
  276. <option value="utp">BT下载数据 (uTP)</option>
  277. <option value="wechat-video">微信视频通话</option>
  278. <option value="dtls">DTLS1.2数据包</option>
  279. <option value="wireguard">WireGuard数据包</option>
  280. </optgroup>
  281. </select>
  282. </div>
  283. <div class="form-group row v2_host">
  284. <label for="v2_host" class="col-md-3 col-form-label">伪装域名</label>
  285. <div class="col-md-4 pl-0">
  286. <input type="text" class="form-control" name="v2_other" id="v2_host">
  287. <div name="v2_ws">
  288. <select data-plugin="selectpicker" data-style="btn-outline btn-primary" class="form-control" id="v2_ws">
  289. <option value="" hidden></option>
  290. @foreach($dvList as $dv)
  291. <option value="{{$dv->domain}}" @if(isset($node) && $node->v2_net == "ws" && $node->v2_host == $dv->domain) selected @endif>{{$dv->domain}}</option>
  292. @endforeach
  293. </select>
  294. </div>
  295. </div>
  296. <div class="text-help offset-md-3"> 伪装类型为http时多个伪装域名逗号隔开,使用WebSocket传输协议时只允许单个</div>
  297. </div>
  298. <div class="form-group row">
  299. <label for="v2_path" class="col-md-3 col-form-label">路径 | 密钥</label>
  300. <input type="text" class="form-control col-md-4" name="v2_path" id="v2_path">
  301. </div>
  302. <div class="form-group row">
  303. <label for="v2_tls" class="col-md-3 col-form-label">连接TLS</label>
  304. <div class="col-md-9">
  305. <input type="checkbox" id="v2_tls" name="v2_tls" data-plugin="switchery" onchange="switchSetting('v2_tls')">
  306. </div>
  307. </div>
  308. <div class="form-group row">
  309. <label for="tls_provider" class="col-md-3 col-form-label">TLS配置</label>
  310. <input type="text" class="form-control col-md-9" name="tls_provider" id="tls_provider"/>
  311. <div class="text-help offset-md-3"> 不同后端配置不同:
  312. <a href="https://proxypanel.gitbook.io/wiki/webapi/webapi-basic-setting#vnet-v2-ray-hou-duan" target="_blank">VNET-V2Ray</a> 、
  313. <a href="https://proxypanel.gitbook.io/wiki/webapi/webapi-basic-setting#v-2-ray-poseidon-hou-duan" target="_blank">V2Ray-Poseidon</a>
  314. </div>
  315. </div>
  316. </div>
  317. <!-- Trojan 设置部分 -->
  318. <div class="trojan-setting hidden">
  319. <div class="form-group row">
  320. <label for="trojan_port" class="col-md-3 col-form-label">连接端口</label>
  321. <input type="number" class="form-control col-md-4" name="port" id="trojan_port" value="443"/>
  322. </div>
  323. </div>
  324. <!-- 中转 设置部分 -->
  325. <hr/>
  326. <div class="form-group row">
  327. <label for="is_subscribe" class="col-md-3 col-form-label">订阅</label>
  328. <div class="col-md-9">
  329. <input type="checkbox" id="is_subscribe" name="is_subscribe" data-plugin="switchery">
  330. </div>
  331. </div>
  332. <div class="form-group row">
  333. <label for="detection_type" class="col-md-3 col-form-label">节点阻断检测</label>
  334. <ul class="col-md-9 list-unstyled list-inline">
  335. <li class="list-inline-item">
  336. <div class="radio-custom radio-primary">
  337. <input type="radio" id="detect_disable" name="detection_type" value="0" checked/>
  338. <label for="detect_disable">关闭</label>
  339. </div>
  340. </li>
  341. <li class="list-inline-item">
  342. <div class="radio-custom radio-primary">
  343. <input type="radio" id="detect_tcp" name="detection_type" value="1"/>
  344. <label for="detect_tcp">只检测TCP</label>
  345. </div>
  346. </li>
  347. <li class="list-inline-item">
  348. <div class="radio-custom radio-primary">
  349. <input type="radio" id="detect_icmp" name="detection_type" value="2"/>
  350. <label for="detect_icmp">只检测ICMP</label>
  351. </div>
  352. </li>
  353. <li class="list-inline-item">
  354. <div class="radio-custom radio-primary">
  355. <input type="radio" id="detect_all" name="detection_type" value="3"/>
  356. <label for="detect_all">检测全部</label>
  357. </div>
  358. </li>
  359. </ul>
  360. <div class="text-help offset-md-3"> 每30~60分钟随机进行节点阻断检测</div>
  361. </div>
  362. <div class="form-group row">
  363. <label for="is_relay" class="col-md-3 col-form-label">中转</label>
  364. <div class="col-md-9">
  365. <input type="checkbox" id="is_relay" name="is_relay" data-plugin="switchery" onchange="switchSetting('is_relay')">
  366. </div>
  367. </div>
  368. <div class="relay-setting hidden">
  369. <div class="form-group row">
  370. <label for="relay_port" class="col-md-3 col-form-label"> 中转端口 </label>
  371. <input type="number" class="form-control col-md-4" name="relay_port" id="relay_port" value="443">
  372. </div>
  373. <div class="form-group row">
  374. <label for="relay_server" class="col-md-3 col-form-label"> 中转地址 </label>
  375. <input type="text" class="form-control col-md-4" name="relay_server" id="relay_server">
  376. </div>
  377. </div>
  378. </div>
  379. </div>
  380. <div class="col-md-12 form-actions">
  381. <button type="submit" class="btn btn-success">提 交</button>
  382. </div>
  383. </div>
  384. </div>
  385. </form>
  386. </div>
  387. </div>
  388. </div>
  389. @endsection
  390. @section('script')
  391. <script src="/assets/global/vendor/bootstrap-select/bootstrap-select.min.js" type="text/javascript"></script>
  392. <script src="/assets/global/js/Plugin/bootstrap-select.js" type="text/javascript"></script>
  393. <script src="/assets/global/vendor/switchery/switchery.min.js" type="text/javascript"></script>
  394. <script src="/assets/global/js/Plugin/switchery.js" type="text/javascript"></script>
  395. <script type="text/javascript">
  396. const string = "{{strtolower(Str::random())}}";
  397. $(document).ready(function () {
  398. let v2_path = $('#v2_path');
  399. @isset($node)
  400. @if($node->is_ddns)
  401. $('#is_ddns').click();
  402. @endif
  403. $('#name').val('{{$node->name}}');
  404. $('#server').val('{{$node->server}}');
  405. $('#ip').val('{{$node->ip}}');
  406. $('#ipv6').val('{{$node->ipv6}}');
  407. $('#push_port').val('{{$node->push_port}}');
  408. $('#traffic_rate').val('{{$node->traffic_rate}}');
  409. $('#level').selectpicker('val', '{{$node->level}}');
  410. $('#speed_limit').val('{{$node->speed_limit/Mbps}}');
  411. $('#client_limit').val('{{$node->client_limit}}');
  412. $('#labels').selectpicker('val', {{$node->labels}});
  413. $('#country_code').selectpicker('val', '{{$node->country_code}}');
  414. $('#description').val('{{$node->description}}');
  415. $('#sort').val('{{$node->sort}}');
  416. @if($node->is_udp)
  417. $('#is_udp').click();
  418. @endif
  419. @if($node->status)
  420. $('#status').click();
  421. @endif
  422. @if($node->is_subscribe)
  423. $('#is_subscribe').click();
  424. @endif
  425. $("input[name='detection_type'][value='{{$node->detection_type}}']").click();
  426. @if($node->single)
  427. $('#single').click();
  428. @endif
  429. $('input[name = port]').val('{{$node->port}}');
  430. $('#passwd').val('{{$node->passwd}}');
  431. $("input[name='type'][value='{{$node->type}}']").click();
  432. @if($node->type == 1 || $node->type == 4)
  433. // ShadowsocksR
  434. $('#method').selectpicker('val', '{{$node->method}}');
  435. $('#protocol').selectpicker('val', '{{$node->protocol}}');
  436. $('#protocol_param').val('{{$node->protocol_param}}');
  437. $('#obfs').selectpicker('val', '{{$node->obfs}}');
  438. $('#obfs_param').val('{{$node->obfs_param}}');
  439. @if($node->compatible)
  440. $('#compatible').click();
  441. @endif
  442. @endif
  443. @if($node->type == 2)
  444. //V2Ray
  445. $('#v2_alter_id').val('{{$node->v2_alter_id}}');
  446. $('#v2_port').val('{{$node->v2_port}}');
  447. $('#v2_method').selectpicker('val', '{{$node->v2_method}}');
  448. $('#v2_net').selectpicker('val', '{{$node->v2_net}}');
  449. $('#v2_type').selectpicker('val', '{{$node->v2_type}}');
  450. $('#v2_host').val('{{$node->v2_host}}');
  451. v2_path.val('{{$node->v2_path}}');
  452. @if($node->v2_tls)
  453. $('#v2_tls').click();
  454. @endif
  455. $('#tls_provider').val('{!! $node->tls_provider !!}');
  456. @endif
  457. @if($node->is_relay)
  458. // 中转
  459. $('#is_relay').click();
  460. $('#relay_port').val('{{$node->relay_port}}');
  461. $('#relay_server').val('{{$node->relay_server}}');
  462. @endif
  463. @else
  464. $('#status').click();
  465. $('#is_udp').click();
  466. $('#is_subscribe').click();
  467. v2_path.val('/' + string);
  468. @endisset
  469. if ($("#obfs").val() === 'plain') {
  470. $('.obfs_param').hide();
  471. }
  472. });
  473. // ajax同步提交
  474. function Submit() {
  475. $.ajax({
  476. type: "POST",
  477. url: @isset($node) "/node/edit" @else "/node/add" @endisset,
  478. async: false,
  479. data: {
  480. _token: '{{csrf_token()}}',
  481. id: '{{Request::get('id')}}',
  482. is_ddns: document.getElementById("is_ddns").checked ? 1 : 0,
  483. name: $('#name').val(),
  484. server: $('#server').val(),
  485. ip: $('#ip').val(),
  486. ipv6: $('#ipv6').val(),
  487. push_port: $('#push_port').val(),
  488. traffic_rate: $('#traffic_rate').val(),
  489. level: $('#level').val(),
  490. speed_limit: $('#speed_limit').val(),
  491. client_limit: $('#client_limit').val(),
  492. labels: $('#labels').val(),
  493. country_code: $('#country_code option:selected').val(),
  494. description: $('#description').val(),
  495. sort: $('#sort').val(),
  496. is_udp: document.getElementById("is_udp").checked ? 1 : 0,
  497. status: document.getElementById("status").checked ? 1 : 0,
  498. type: $("input[name='type']:checked").val(),
  499. method: $('#method').val(),
  500. protocol: $('#protocol').val(),
  501. protocol_param: $('#protocol_param').val(),
  502. obfs: $('#obfs').val(),
  503. obfs_param: $('#obfs_param').val(),
  504. compatible: document.getElementById("compatible").checked ? 1 : 0,
  505. is_subscribe: document.getElementById("is_subscribe").checked ? 1 : 0,
  506. detection_type: $("input[name='detection_type']:checked").val(),
  507. single: document.getElementById("single").checked ? 1 : 0,
  508. port: $("input[name='port']").val(),
  509. passwd: $('#passwd').val(),
  510. v2_alter_id: $('#v2_alter_id').val(),
  511. v2_port: $('#v2_port').val(),
  512. v2_method: $("#v2_method").val(),
  513. v2_net: $('#v2_net').val(),
  514. v2_type: $('#v2_type').val(),
  515. v2_host: $('#v2_host').val(),
  516. v2_path: $('#v2_path').val(),
  517. v2_tls: document.getElementById("v2_tls").checked ? 1 : 0,
  518. tls_provider: $('#tls_provider').val(),
  519. is_relay: document.getElementById("is_relay").checked ? 1 : 0,
  520. relay_port: $('#relay_port').val(),
  521. relay_server: $('#relay_server').val(),
  522. },
  523. dataType: 'json',
  524. success: function (ret) {
  525. if (ret.status === 'success') {
  526. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false})
  527. .then(() => window.location.href = '/node')
  528. } else {
  529. swal.fire({
  530. title: '[错误 | Error]',
  531. text: ret.message,
  532. type: 'error'
  533. });
  534. }
  535. }
  536. });
  537. return false;
  538. }
  539. function switchSetting(id) {
  540. let check = document.getElementById(id).checked ? 1 : 0;
  541. switch (id) {
  542. // 设置单端口多用户
  543. case 'single':
  544. if (check) {
  545. $(".single-setting").show();
  546. } else {
  547. $('#single_port').val('');
  548. $('#passwd').val('');
  549. $(".single-setting").hide();
  550. }
  551. break;
  552. //设置中转
  553. case 'is_relay':
  554. if (check) {
  555. $(".relay-setting").show();
  556. $("#relay_port").attr("required", "required");
  557. $("#relay_server").attr("required", "required");
  558. } else {
  559. $(".relay-setting").hide();
  560. $("#relay_port").removeAttr("required");
  561. $("#relay_server").removeAttr("required");
  562. }
  563. break;
  564. // 设置是否使用DDNS
  565. case 'is_ddns':
  566. if (check) {
  567. $("#ip").val("1.1.1.1").attr("readonly", "readonly");
  568. $("#server").attr("required", "required");
  569. } else {
  570. $("#ip").val("").removeAttr("readonly");
  571. $("#server").removeAttr("required");
  572. }
  573. break;
  574. default:
  575. break;
  576. }
  577. }
  578. // 设置服务类型
  579. $("input:radio[name='type']").on('change', function () {
  580. const type = parseInt($(this).val());
  581. const $ssr_setting = $(".ssr-setting");
  582. const $v2ray_setting = $(".v2ray-setting");
  583. const $trojan_setting = $(".trojan-setting");
  584. $ssr_setting.hide();
  585. $v2ray_setting.hide();
  586. $trojan_setting.hide();
  587. switch (type) {
  588. case 1:
  589. $ssr_setting.show();
  590. break;
  591. case 2:
  592. $v2ray_setting.show();
  593. $('#v2_net').selectpicker('val', 'tcp');
  594. break;
  595. case 3:
  596. $trojan_setting.show();
  597. break;
  598. case 4:
  599. $ssr_setting.show();
  600. break;
  601. default:
  602. }
  603. });
  604. $("#obfs").on('changed.bs.select', function (e, clickedIndex, isSelected, previousValue) {
  605. const obfs_param = $('.obfs_param');
  606. if ($("#obfs").val() === 'plain') {
  607. $("#obfs_param").val('');
  608. obfs_param.hide();
  609. } else {
  610. obfs_param.show();
  611. }
  612. });
  613. $("#v2_ws").on('changed.bs.select', function (e, clickedIndex, isSelected, previousValue) {
  614. $('#v2_host').val($('#v2_ws').val());
  615. })
  616. // 设置V2Ray详细设置
  617. $("#v2_net").on('changed.bs.select', function (e, clickedIndex, isSelected, previousValue) {
  618. const type = $('.v2_type');
  619. const type_option = $('#type_option');
  620. const host = $('.v2_host');
  621. const path = $('#v2_path');
  622. const v2_ws = $('[name="v2_ws"]');
  623. const v2_other = $('[name="v2_other"]');
  624. type.show();
  625. host.show();
  626. v2_other.show();
  627. v2_ws.hide();
  628. path.val('/' + string);
  629. switch ($(this).val()) {
  630. case 'kcp':
  631. type_option.attr('disabled', false);
  632. break;
  633. case 'ws':
  634. v2_ws.show();
  635. type.hide();
  636. v2_other.hide();
  637. break;
  638. case 'http':
  639. type.hide();
  640. break;
  641. case 'domainsocket':
  642. type.hide();
  643. host.hide();
  644. break;
  645. case 'quic':
  646. type_option.attr('disabled', false);
  647. path.val(string);
  648. break;
  649. case 'tcp':
  650. default:
  651. type_option.attr('disabled', true);
  652. break;
  653. }
  654. $('#v2_type').selectpicker('refresh');
  655. });
  656. // 服务条款
  657. function showTnc() {
  658. const content =
  659. '<ol>' +
  660. '<li>请勿直接复制黏贴以下配置,SSR(R)会报错的</li>' +
  661. '<li>确保服务器时间为CST</li>' +
  662. '</ol>' +
  663. '&emsp;&emsp;"additional_ports" : {<br />' +
  664. '&emsp;&emsp;&emsp;"443": {<br />' +
  665. '&emsp;&emsp;&emsp;&emsp;"passwd": "ProxyPanel",<br />' +
  666. '&emsp;&emsp;&emsp;&emsp;"method": "none",<br />' +
  667. '&emsp;&emsp;&emsp;&emsp;"protocol": "auth_chain_a",<br />' +
  668. '&emsp;&emsp;&emsp;&emsp;"protocol_param": "#",<br />' +
  669. '&emsp;&emsp;&emsp;&emsp;"obfs": "plain",<br />' +
  670. '&emsp;&emsp;&emsp;&emsp;"obfs_param": "fe2.update.microsoft.com"<br />' +
  671. '&emsp;&emsp;&emsp;}<br />' +
  672. '&emsp;&emsp;},';
  673. swal.fire({
  674. title: '[节点 user-config.json 配置示例]',
  675. html: '<div class="p-10 bg-grey-900 text-white font-weight-300 text-left" style="line-height: 22px;">' + content + '</div>',
  676. type: 'info'
  677. });
  678. }
  679. // 模式提示
  680. function showPortsOnlyConfig() {
  681. const content = '严格模式:"additional_ports_only": "true"'
  682. + '<br><br>'
  683. + '兼容模式:"additional_ports_only": "false"';
  684. swal.fire({
  685. title: '[节点 user-config.json 配置示例]',
  686. html: '<div class="p-10 bg-grey-900 text-white font-weight-300 text-left" style="line-height: 22px;">' + content + '</div>',
  687. type: 'info'
  688. });
  689. }
  690. </script>
  691. @endsection