info.blade.php 46 KB

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