| 
									
										
										
										
											2023-02-09 19:18:06 +00:00
										 |  |  | {{define "inboundModal"}} | 
					
						
							|  |  |  | <a-modal id="inbound-modal" v-model="inModal.visible" :title="inModal.title" @ok="inModal.ok" | 
					
						
							|  |  |  |          :confirm-loading="inModal.confirmLoading" :closable="true" :mask-closable="false" | 
					
						
							| 
									
										
										
										
											2023-05-08 14:44:22 +00:00
										 |  |  |          :class="themeSwitcher.darkCardClass" | 
					
						
							| 
									
										
										
										
											2023-02-09 19:18:06 +00:00
										 |  |  |          :ok-text="inModal.okText" cancel-text='{{ i18n "close" }}'> | 
					
						
							|  |  |  |     {{template "form/inbound"}} | 
					
						
							|  |  |  | </a-modal> | 
					
						
							|  |  |  | <script> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const inModal = { | 
					
						
							|  |  |  |         title: '', | 
					
						
							|  |  |  |         visible: false, | 
					
						
							|  |  |  |         confirmLoading: false, | 
					
						
							|  |  |  |         okText: '{{ i18n "sure" }}', | 
					
						
							|  |  |  |         isEdit: false, | 
					
						
							|  |  |  |         confirm: null, | 
					
						
							|  |  |  |         inbound: new Inbound(), | 
					
						
							|  |  |  |         dbInbound: new DBInbound(), | 
					
						
							|  |  |  |         ok() { | 
					
						
							|  |  |  |             ObjectUtil.execute(inModal.confirm, inModal.inbound, inModal.dbInbound); | 
					
						
							|  |  |  |         }, | 
					
						
							| 
									
										
										
										
											2023-05-08 14:44:22 +00:00
										 |  |  |         show({ title = '', okText = '{{ i18n "sure" }}', inbound = null, dbInbound = null, confirm = (inbound, dbInbound) => {}, isEdit = false }) { | 
					
						
							| 
									
										
										
										
											2023-02-09 19:18:06 +00:00
										 |  |  |             this.title = title; | 
					
						
							|  |  |  |             this.okText = okText; | 
					
						
							|  |  |  |             if (inbound) { | 
					
						
							|  |  |  |                 this.inbound = Inbound.fromJson(inbound.toJson()); | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 this.inbound = new Inbound(); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             if (dbInbound) { | 
					
						
							|  |  |  |                 this.dbInbound = new DBInbound(dbInbound); | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 this.dbInbound = new DBInbound(); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             this.confirm = confirm; | 
					
						
							|  |  |  |             this.visible = true; | 
					
						
							|  |  |  |             this.isEdit = isEdit; | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         close() { | 
					
						
							|  |  |  |             inModal.visible = false; | 
					
						
							|  |  |  |             inModal.loading(false); | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         loading(loading) { | 
					
						
							|  |  |  |             inModal.confirmLoading = loading; | 
					
						
							|  |  |  |         }, | 
					
						
							| 
									
										
										
										
											2023-04-18 18:04:06 +00:00
										 |  |  |         getClients(protocol, clientSettings) { | 
					
						
							| 
									
										
										
										
											2023-05-08 14:44:22 +00:00
										 |  |  |             switch (protocol) { | 
					
						
							| 
									
										
										
										
											2023-04-18 18:04:06 +00:00
										 |  |  |                 case Protocols.VMESS: return clientSettings.vmesses; | 
					
						
							|  |  |  |                 case Protocols.VLESS: return clientSettings.vlesses; | 
					
						
							|  |  |  |                 case Protocols.TROJAN: return clientSettings.trojans; | 
					
						
							| 
									
										
										
										
											2023-05-06 16:51:14 +00:00
										 |  |  |                 case Protocols.SHADOWSOCKS: return clientSettings.shadowsockses; | 
					
						
							| 
									
										
										
										
											2023-04-18 18:04:06 +00:00
										 |  |  |                 default: return null; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         }, | 
					
						
							| 
									
										
										
										
											2023-02-09 19:18:06 +00:00
										 |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const protocols = { | 
					
						
							|  |  |  |         VMESS: Protocols.VMESS, | 
					
						
							|  |  |  |         VLESS: Protocols.VLESS, | 
					
						
							|  |  |  |         TROJAN: Protocols.TROJAN, | 
					
						
							|  |  |  |         SHADOWSOCKS: Protocols.SHADOWSOCKS, | 
					
						
							|  |  |  |         DOKODEMO: Protocols.DOKODEMO, | 
					
						
							|  |  |  |         SOCKS: Protocols.SOCKS, | 
					
						
							|  |  |  |         HTTP: Protocols.HTTP, | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     new Vue({ | 
					
						
							|  |  |  |         delimiters: ['[[', ']]'], | 
					
						
							|  |  |  |         el: '#inbound-modal', | 
					
						
							|  |  |  |         data: { | 
					
						
							|  |  |  |             inModal: inModal, | 
					
						
							|  |  |  |             Protocols: protocols, | 
					
						
							|  |  |  |             SSMethods: SSMethods, | 
					
						
							| 
									
										
										
										
											2023-04-18 18:04:06 +00:00
										 |  |  |             delayedStart: false, | 
					
						
							| 
									
										
										
										
											2023-02-09 19:18:06 +00:00
										 |  |  |             get inbound() { | 
					
						
							|  |  |  |                 return inModal.inbound; | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             get dbInbound() { | 
					
						
							|  |  |  |                 return inModal.dbInbound; | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             get isEdit() { | 
					
						
							|  |  |  |                 return inModal.isEdit; | 
					
						
							|  |  |  |             }, | 
					
						
							| 
									
										
										
										
											2023-04-18 18:04:06 +00:00
										 |  |  |             get client() { | 
					
						
							|  |  |  |                 return inModal.getClients(this.inbound.protocol, this.inbound.settings)[0]; | 
					
						
							| 
									
										
										
										
											2023-02-09 19:18:06 +00:00
										 |  |  |             }, | 
					
						
							| 
									
										
										
										
											2023-04-18 18:04:06 +00:00
										 |  |  |             get delayedExpireDays() { | 
					
						
							|  |  |  |                 return this.client && this.client.expiryTime < 0 ? this.client.expiryTime / -86400000 : 0; | 
					
						
							| 
									
										
										
										
											2023-02-09 19:18:06 +00:00
										 |  |  |             }, | 
					
						
							| 
									
										
										
										
											2023-05-08 14:44:22 +00:00
										 |  |  |             set delayedExpireDays(days) { | 
					
						
							| 
									
										
										
										
											2023-04-18 18:04:06 +00:00
										 |  |  |                 this.client.expiryTime = -86400000 * days; | 
					
						
							| 
									
										
										
										
											2023-02-09 19:18:06 +00:00
										 |  |  |             }, | 
					
						
							| 
									
										
										
										
											2023-04-18 18:04:06 +00:00
										 |  |  |         }, | 
					
						
							|  |  |  |         methods: { | 
					
						
							|  |  |  |             streamNetworkChange() { | 
					
						
							|  |  |  |                 if (!inModal.inbound.canSetTls()) { | 
					
						
							|  |  |  |                     this.inModal.inbound.stream.security = 'none'; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 if (!inModal.inbound.canEnableReality()) { | 
					
						
							|  |  |  |                     this.inModal.inbound.reality = false; | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2023-02-09 19:18:06 +00:00
										 |  |  |             }, | 
					
						
							| 
									
										
										
										
											2023-05-08 14:44:22 +00:00
										 |  |  |             setDefaultCertData() { | 
					
						
							| 
									
										
										
										
											2023-04-09 19:43:18 +00:00
										 |  |  |                 inModal.inbound.stream.tls.certs[0].certFile = app.defaultCert; | 
					
						
							|  |  |  |                 inModal.inbound.stream.tls.certs[0].keyFile = app.defaultKey; | 
					
						
							|  |  |  |             }, | 
					
						
							| 
									
										
										
										
											2023-05-08 14:44:22 +00:00
										 |  |  |             setDefaultCertXtls() { | 
					
						
							| 
									
										
										
										
											2023-05-01 17:28:00 +00:00
										 |  |  |                 inModal.inbound.stream.xtls.certs[0].certFile = app.defaultCert; | 
					
						
							|  |  |  |                 inModal.inbound.stream.xtls.certs[0].keyFile = app.defaultKey; | 
					
						
							|  |  |  |             }, | 
					
						
							| 
									
										
										
										
											2023-05-08 14:44:22 +00:00
										 |  |  |             async getNewX25519Cert() { | 
					
						
							| 
									
										
										
										
											2023-04-18 18:04:06 +00:00
										 |  |  |                 inModal.loading(true); | 
					
						
							|  |  |  |                 const msg = await HttpUtil.post('/server/getNewX25519Cert'); | 
					
						
							|  |  |  |                 inModal.loading(false); | 
					
						
							|  |  |  |                 if (!msg.success) { | 
					
						
							|  |  |  |                     return; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 inModal.inbound.stream.reality.privateKey = msg.obj.privateKey; | 
					
						
							|  |  |  |                 inModal.inbound.stream.reality.settings.publicKey = msg.obj.publicKey; | 
					
						
							| 
									
										
										
										
											2023-02-09 19:18:06 +00:00
										 |  |  |             } | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | </script> | 
					
						
							| 
									
										
										
										
											2023-03-17 16:07:49 +00:00
										 |  |  | {{end}} |