temp
This commit is contained in:
		
							
								
								
									
										11
									
								
								src/module/html/stat/index.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								src/module/html/stat/index.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,11 @@
 | 
			
		||||
/**
 | 
			
		||||
 * 添加统计脚本
 | 
			
		||||
 * @param html
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
export const addStat = (html: string) => {
 | 
			
		||||
  return html.replace(
 | 
			
		||||
    '</head>',
 | 
			
		||||
    `<script defer src="https://umami.xiongxiao.me/script.js" data-website-id="79e7aa98-9e6e-4eef-bc8b-9cbd0ecb11c3"></script></head>`,
 | 
			
		||||
  );
 | 
			
		||||
};
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
import { getDNS, isLocalhost } from '@/utils/dns.ts';
 | 
			
		||||
import { getDNS, isIpv4OrIpv6, isLocalhost } from '@/utils/dns.ts';
 | 
			
		||||
import http from 'http';
 | 
			
		||||
import { UserApp } from './get-user-app.ts';
 | 
			
		||||
import { config, fileStore } from '../module/config.ts';
 | 
			
		||||
@@ -104,6 +104,13 @@ export const handleRequest = async (req: http.IncomingMessage, res: http.ServerR
 | 
			
		||||
    // app = 'codeflow';
 | 
			
		||||
    // domainApp = true;
 | 
			
		||||
  } else {
 | 
			
		||||
    if (isIpv4OrIpv6(dns.hostName)) {
 | 
			
		||||
      // 打印出 req.url 和错误信息
 | 
			
		||||
      console.error('Invalid domain: ', req.url, dns.hostName);
 | 
			
		||||
      res.writeHead(404, { 'Content-Type': 'text/plain' });
 | 
			
		||||
      res.end('Invalid domain\n');
 | 
			
		||||
      return res.end();
 | 
			
		||||
    }
 | 
			
		||||
    // 验证域名
 | 
			
		||||
    if (dns.hostName !== domain) {
 | 
			
		||||
      // redis获取域名对应的用户和应用
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user