@@ -89,7 +89,7 @@ export default {
8989 proxyIP = env . PROXYIP || env . proxyip || proxyIP ;
9090 proxyIPs = await 整理 ( proxyIP ) ;
9191 proxyIP = proxyIPs [ Math . floor ( Math . random ( ) * proxyIPs . length ) ] ;
92- DNS64Server = env . DNS64 || env . NAT64 || ( DNS64Server != '' ? DNS64Server : atob ( "ZG5zNjQuY21saXVzc3NzLm5ldA==" ) ) ;
92+ DNS64Server = env . DNS64 || env . NAT64 || DNS64Server ;
9393 socks5Address = env . HTTP || env . SOCKS5 || socks5Address ;
9494 socks5s = await 整理 ( socks5Address ) ;
9595 socks5Address = socks5s [ Math . floor ( Math . random ( ) * socks5s . length ) ] ;
@@ -2471,6 +2471,29 @@ async function KV(request, env, txt = 'ADD.txt') {
24712471}
24722472
24732473async function resolveToIPv6 ( target ) {
2474+ if ( ! DNS64Server ) {
2475+ const defaultAddress = atob ( 'cHJveHlpcC5jbWxpdXNzc3MubmV0' ) ;
2476+ try {
2477+ const response = await fetch ( atob ( 'aHR0cHM6Ly8xLjEuMS4xL2Rucy1xdWVyeT9uYW1lPW5hdDY0LmNtbGl1c3Nzcy5uZXQmdHlwZT1UWFQ=' ) , {
2478+ headers : { 'Accept' : 'application/dns-json' }
2479+ } ) ;
2480+
2481+ if ( ! response . ok ) return defaultAddress ;
2482+ const data = await response . json ( ) ;
2483+ const txtRecords = ( data . Answer || [ ] ) . filter ( record => record . type === 16 ) . map ( record => record . data ) ;
2484+
2485+ if ( txtRecords . length === 0 ) return defaultAddress ;
2486+ let txtData = txtRecords [ 0 ] ;
2487+ if ( txtData . startsWith ( '"' ) && txtData . endsWith ( '"' ) ) txtData = txtData . slice ( 1 , - 1 ) ;
2488+ const prefixes = txtData . replace ( / \\ 0 1 0 / g, '\n' ) . split ( '\n' ) . filter ( prefix => prefix . trim ( ) ) ;
2489+ if ( prefixes . length === 0 ) return defaultAddress ;
2490+ DNS64Server = prefixes [ Math . floor ( Math . random ( ) * prefixes . length ) ] ;
2491+ } catch ( error ) {
2492+ console . error ( 'DNS64Server查询失败:' , error ) ;
2493+ return defaultAddress ;
2494+ }
2495+ }
2496+
24742497 // 检查是否为IPv4
24752498 function isIPv4 ( str ) {
24762499 const parts = str . split ( '.' ) ;
@@ -2663,7 +2686,7 @@ async function resolveToIPv6(target) {
26632686 return isIPv6 ( nat64 ) ? nat64 : atob ( 'cHJveHlpcC5jbWxpdXNzc3MubmV0' ) ;
26642687 } catch ( error ) {
26652688 console . error ( '解析错误:' , error ) ;
2666- return atob ( 'cHJveHlpcC5jbWxpdXNzc3MubmV0' ) ; ;
2689+ return atob ( 'cHJveHlpcC5jbWxpdXNzc3MubmV0' ) ;
26672690 }
26682691}
26692692
0 commit comments