mirror of
				https://github.com/MHSanaei/3x-ui.git
				synced 2025-10-29 19:32:51 +00:00 
			
		
		
		
	 fe9f0d1d0e
			
		
	
	
		fe9f0d1d0e
		
			
		
	
	
	
		
			
	
		
	
	
		
			Some checks are pending
		
		
	
	Release 3X-UI / build (386) (push) Waiting to run
				
			Release 3X-UI / build (amd64) (push) Waiting to run
				
			Release 3X-UI / build (arm64) (push) Waiting to run
				
			Release 3X-UI / build (armv5) (push) Waiting to run
				
			Release 3X-UI / build (armv6) (push) Waiting to run
				
			Release 3X-UI / build (armv7) (push) Waiting to run
				
			Release 3X-UI / build (s390x) (push) Waiting to run
				
			
		
			
				
	
	
		
			206 lines
		
	
	
		
			No EOL
		
	
	
		
			8.1 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			206 lines
		
	
	
		
			No EOL
		
	
	
		
			8.1 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
| {{define "modals/inboundModal"}}
 | |
| <a-modal id="inbound-modal" v-model="inModal.visible" :title="inModal.title" :dialog-style="{ top: '20px' }"
 | |
|     @ok="inModal.ok" :confirm-loading="inModal.confirmLoading" :closable="true" :mask-closable="false"
 | |
|     :class="themeSwitcher.currentTheme" :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);
 | |
|         },
 | |
|         show({ title = '', okText = '{{ i18n "sure" }}', inbound = null, dbInbound = null, confirm = (inbound, dbInbound) => { }, isEdit = false }) {
 | |
|             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 = true) {
 | |
|             inModal.confirmLoading = loading;
 | |
|         },
 | |
|     };
 | |
| 
 | |
|     new Vue({
 | |
|         delimiters: ['[[', ']]'],
 | |
|         el: '#inbound-modal',
 | |
|         data: {
 | |
|             inModal: inModal,
 | |
|             delayedStart: false,
 | |
|             get inbound() {
 | |
|                 return inModal.inbound;
 | |
|             },
 | |
|             get dbInbound() {
 | |
|                 return inModal.dbInbound;
 | |
|             },
 | |
|             get isEdit() {
 | |
|                 return inModal.isEdit;
 | |
|             },
 | |
|             get client() {
 | |
|                 return inModal.inbound.clients[0];
 | |
|             },
 | |
|             get datepicker() {
 | |
|                 return app.datepicker;
 | |
|             },
 | |
|             get delayedExpireDays() {
 | |
|                 return this.client && this.client.expiryTime < 0 ? this.client.expiryTime / -86400000 : 0;
 | |
|             },
 | |
|             set delayedExpireDays(days) {
 | |
|                 this.client.expiryTime = -86400000 * days;
 | |
|             },
 | |
|             get externalProxy() {
 | |
|                 return this.inbound.stream.externalProxy.length > 0;
 | |
|             },
 | |
|             set externalProxy(value) {
 | |
|                 if (value) {
 | |
|                     inModal.inbound.stream.externalProxy = [{
 | |
|                         forceTls: "same",
 | |
|                         dest: window.location.hostname,
 | |
|                         port: inModal.inbound.port,
 | |
|                         remark: ""
 | |
|                     }];
 | |
|                 } else {
 | |
|                     inModal.inbound.stream.externalProxy = [];
 | |
|                 }
 | |
|             }
 | |
|         },
 | |
|         methods: {
 | |
|             streamNetworkChange() {
 | |
|                 if (!inModal.inbound.canEnableTls()) {
 | |
|                     this.inModal.inbound.stream.security = 'none';
 | |
|                 }
 | |
|                 if (!inModal.inbound.canEnableReality()) {
 | |
|                     this.inModal.inbound.reality = false;
 | |
|                 }
 | |
|                 if (this.inModal.inbound.protocol == Protocols.VLESS && !inModal.inbound.canEnableTlsFlow()) {
 | |
|                     this.inModal.inbound.settings.vlesses.forEach(client => {
 | |
|                         client.flow = "";
 | |
|                     });
 | |
|                 }
 | |
|             },
 | |
|             SSMethodChange() {
 | |
|                 this.inModal.inbound.settings.password = RandomUtil.randomShadowsocksPassword(this.inModal.inbound.settings.method)
 | |
| 
 | |
|                 if (this.inModal.inbound.isSSMultiUser) {
 | |
|                     if (this.inModal.inbound.settings.shadowsockses.length == 0) {
 | |
|                         this.inModal.inbound.settings.shadowsockses = [new Inbound.ShadowsocksSettings.Shadowsocks()];
 | |
|                     }
 | |
|                     if (!this.inModal.inbound.isSS2022) {
 | |
|                         this.inModal.inbound.settings.shadowsockses.forEach(client => {
 | |
|                             client.method = this.inModal.inbound.settings.method;
 | |
|                         })
 | |
|                     } else {
 | |
|                         this.inModal.inbound.settings.shadowsockses.forEach(client => {
 | |
|                             client.method = "";
 | |
|                         })
 | |
|                     }
 | |
|                     this.inModal.inbound.settings.shadowsockses.forEach(client => {
 | |
|                         client.password = RandomUtil.randomShadowsocksPassword(this.inModal.inbound.settings.method)
 | |
|                     })
 | |
|                 } else {
 | |
|                     if (this.inModal.inbound.settings.shadowsockses.length > 0) {
 | |
|                         this.inModal.inbound.settings.shadowsockses = [];
 | |
|                     }
 | |
|                 }
 | |
|             },
 | |
|             setDefaultCertData(index) {
 | |
|                 inModal.inbound.stream.tls.certs[index].certFile = app.defaultCert;
 | |
|                 inModal.inbound.stream.tls.certs[index].keyFile = app.defaultKey;
 | |
|             },
 | |
|             async getNewX25519Cert() {
 | |
|                 inModal.loading(true);
 | |
|                 const msg = await HttpUtil.get('/panel/api/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;
 | |
|             },
 | |
|             clearX25519Cert() {
 | |
|                 this.inbound.stream.reality.privateKey = '';
 | |
|                 this.inbound.stream.reality.settings.publicKey = '';
 | |
|             },
 | |
|             async getNewmldsa65() {
 | |
|                 inModal.loading(true);
 | |
|                 const msg = await HttpUtil.get('/panel/api/server/getNewmldsa65');
 | |
|                 inModal.loading(false);
 | |
|                 if (!msg.success) {
 | |
|                     return;
 | |
|                 }
 | |
|                 inModal.inbound.stream.reality.mldsa65Seed = msg.obj.seed;
 | |
|                 inModal.inbound.stream.reality.settings.mldsa65Verify = msg.obj.verify;
 | |
|             },
 | |
|             clearMldsa65() {
 | |
|                 this.inbound.stream.reality.mldsa65Seed = '';
 | |
|                 this.inbound.stream.reality.settings.mldsa65Verify = '';
 | |
|             },
 | |
|             async getNewEchCert() {
 | |
|                 inModal.loading(true);
 | |
|                 const msg = await HttpUtil.post('/panel/api/server/getNewEchCert', { sni: inModal.inbound.stream.tls.sni });
 | |
|                 inModal.loading(false);
 | |
|                 if (!msg.success) {
 | |
|                     return;
 | |
|                 }
 | |
|                 inModal.inbound.stream.tls.echServerKeys = msg.obj.echServerKeys;
 | |
|                 inModal.inbound.stream.tls.settings.echConfigList = msg.obj.echConfigList;
 | |
|             },
 | |
|             clearEchCert() {
 | |
|                 this.inbound.stream.tls.echServerKeys = '';
 | |
|                 this.inbound.stream.tls.settings.echConfigList = '';
 | |
|             },
 | |
|             async getNewVlessEnc() {
 | |
|                 inModal.loading(true);
 | |
|                 const msg = await HttpUtil.get('/panel/api/server/getNewVlessEnc');
 | |
|                 inModal.loading(false);
 | |
| 
 | |
|                 if (!msg.success) {
 | |
|                     return;
 | |
|                 }
 | |
| 
 | |
|                 const auths = msg.obj.auths || [];
 | |
|                 const selected = inModal.inbound.settings.selectedAuth;
 | |
|                 const block = auths.find(a => a.label === selected);
 | |
| 
 | |
|                 if (!block) {
 | |
|                     console.error("No auth block for", selected);
 | |
|                     return;
 | |
|                 }
 | |
| 
 | |
|                 inModal.inbound.settings.decryption = block.decryption;
 | |
|                 inModal.inbound.settings.encryption = block.encryption;
 | |
|             },
 | |
|             clearVlessEnc() {
 | |
|                 this.inbound.settings.decryption = 'none';
 | |
|                 this.inbound.settings.encryption = 'none';
 | |
|                 this.inbound.settings.selectedAuth = undefined;
 | |
|             }
 | |
| 
 | |
|         },
 | |
|     });
 | |
| 
 | |
| </script>
 | |
| {{end}} |