Browse Source

修复 bug

张富强 4 months ago
parent
commit
bf2050582e
5 changed files with 14 additions and 7 deletions
  1. 1 1
      dns/dns_windows.go
  2. 1 1
      dns/dns_windows_test.go
  3. 8 3
      fast/main.go
  4. 2 1
      hpsocket/client_windows_extend.go
  5. 2 1
      phone/query_windows_test.go

+ 1 - 1
dns/dns_windows.go

@@ -1,6 +1,6 @@
 //go:build windows
 
-package dns
+package yu_dns
 
 import (
 	yu_math "gogs.qqck.cn/s/go-tools/math"

+ 1 - 1
dns/dns_windows_test.go

@@ -1,4 +1,4 @@
-package dns
+package yu_dns
 
 import (
 	"fmt"

+ 8 - 3
fast/main.go

@@ -54,7 +54,9 @@ func P2B[T int | uintptr](ptr T, size T) []byte {
 		Len:  uintptr(size),
 		Cap:  uintptr(size),
 	}
-	return *(*[]byte)(unsafe.Pointer(&j_slice))
+	j_bufs := make([]byte, size)
+	copy(*(*[]byte)(unsafe.Pointer(&j_slice)), j_bufs)
+	return j_bufs
 }
 
 // P2S
@@ -64,9 +66,12 @@ func P2B[T int | uintptr](ptr T, size T) []byte {
 //	@param size 数据尺寸
 //	@return []byte 转换结果
 func P2S[T int | uintptr](ptr T, size T) string {
-	j_string := StringHeader{
+	j_slice := SliceHeader{
 		Data: uintptr(ptr),
 		Len:  uintptr(size),
+		Cap:  uintptr(size),
 	}
-	return *(*string)(unsafe.Pointer(&j_string))
+	j_bufs := make([]byte, size)
+	copy(*(*[]byte)(unsafe.Pointer(&j_slice)), j_bufs)
+	return string(j_bufs)
 }

+ 2 - 1
hpsocket/client_windows_extend.go

@@ -5,6 +5,7 @@ package yu_hpsocket
 import (
 	yu_base64 "gogs.qqck.cn/s/go-tools/base64"
 	yu_dns "gogs.qqck.cn/s/go-tools/dns"
+	yu_fast "gogs.qqck.cn/s/go-tools/fast"
 	yu_proxy "gogs.qqck.cn/s/go-tools/proxy"
 	yu_strconv "gogs.qqck.cn/s/go-tools/strconv"
 	"net/netip"
@@ -55,7 +56,7 @@ func (t *Client[T]) connect_proxy() bool {
 			return false
 		}
 		// "HTTP/1.1 200 Connection Established"、"HTTP/1.1 200 Connection established"
-		if len(j_buf) < 16 || string(j_buf[9:12]) != "200" {
+		if len(j_buf) < 16 || yu_fast.B2S(j_buf[9:12]) != "200" {
 			t.Stop()
 			return false
 		}

+ 2 - 1
phone/query_windows_test.go

@@ -9,7 +9,8 @@ import (
 )
 
 func TestQuery(t *testing.T) {
-	fmt.Println(Query("17638584853"))
+	fmt.Println(Query("13564826141"))
+	fmt.Println("17638584853"[5:])
 	j_str := `
 
 `