fix(dns) remove dns.alidns.com
This commit is contained in:
parent
50620a2153
commit
2d997dcdcf
4
.github/workflows/release.yml
vendored
4
.github/workflows/release.yml
vendored
@ -43,10 +43,10 @@ jobs:
|
||||
|
||||
- name: Build Libraries
|
||||
env:
|
||||
NDK_TOOLCHAIN: ${{ steps.setup-ndk.outputs.ndk-path }}
|
||||
NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
|
||||
BUILD_MACHINE: linux
|
||||
run: |
|
||||
echo NDK path is $NDK_TOOLCHAIN
|
||||
echo NDK path is $NDK_HOME
|
||||
make -e
|
||||
|
||||
- name: Upload Binaries to Release
|
||||
|
8
.github/workflows/test.yml
vendored
8
.github/workflows/test.yml
vendored
@ -35,16 +35,16 @@ jobs:
|
||||
|
||||
- name: Test Build
|
||||
env:
|
||||
NDK_TOOLCHAIN: ${{ steps.setup-ndk.outputs.ndk-path }}
|
||||
NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
|
||||
BUILD_MACHINE: linux
|
||||
run: |
|
||||
echo NDK path is $NDK_TOOLCHAIN
|
||||
ls $NDK_TOOLCHAIN
|
||||
echo NDK path is $NDK_HOME
|
||||
ls $NDK_HOME
|
||||
make -e
|
||||
|
||||
- name: Build and Run Tests
|
||||
env:
|
||||
NDK_TOOLCHAIN: ${{ steps.setup-ndk.outputs.ndk-path }}
|
||||
NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
|
||||
BUILD_MACHINE: linux
|
||||
GOARCH: amd64
|
||||
run: make -e runtest
|
||||
|
18
Makefile
18
Makefile
@ -13,12 +13,12 @@ TARGET_ARCH := aarch64 # optional: armv7a i686 x86_64
|
||||
|
||||
CGO_ENABLED := 1
|
||||
GO_SRC := $(shell find . -name '*.go' | grep -v '_test.go$$')
|
||||
NDK_TOOLCHAIN := ~/Library/Android/sdk/ndk/$(NDK_VERSION)/toolchains/llvm/prebuilt/$(BUILD_MACHINE)-$(BUILD_ARCH)
|
||||
NDK_HOME := ~/Library/Android/sdk/ndk/$(NDK_VERSION)
|
||||
NDK_TOOLCHAIN := $(NDK_HOME)/toolchains/llvm/prebuilt/$(BUILD_MACHINE)-$(BUILD_ARCH)
|
||||
CC := $(NDK_TOOLCHAIN)/bin/$(TARGET_ARCH)-linux-$(TARGET_SDK)-clang
|
||||
TEST_OUTPUT = '$(shell cd $(BUILD_PATH) && ./test | head -c 12)'
|
||||
TEST_EXPECTED = '{"code":200,'
|
||||
TEST_EXPECTED := '{"code":200,'
|
||||
|
||||
all: clean
|
||||
all:
|
||||
@BUILD_PATH=$(BUILD_PATH)/aarch64 TARGET_ARCH=aarch64 GOARCH=arm64 $(MAKE) -e shared
|
||||
@BUILD_PATH=$(BUILD_PATH)/armv7a TARGET_ARCH=armv7a GOARCH=arm TARGET_SDK=androideabi23 $(MAKE) -e shared
|
||||
@BUILD_PATH=$(BUILD_PATH)/i686 TARGET_ARCH=i686 GOARCH=amd64 $(MAKE) -e shared
|
||||
@ -32,11 +32,15 @@ shared: $(GO_SRC) dir tidy
|
||||
test: dir
|
||||
@GOOS=$(BUILD_MACHINE) CC=cc NDK_TOOLCHAIN="" $(MAKE) -e shared
|
||||
cc -o $(BUILD_PATH)/test $(BUILD_PATH)/test.c -l$(PROJECT_NAME) -L$(BUILD_PATH)
|
||||
runtest: test
|
||||
@if [ $(TEST_OUTPUT) = $(TEST_EXPECTED) ]; then \
|
||||
runtest:
|
||||
@if [ ! -f "$(BUILD_PATH)/test" ]; then \
|
||||
$(MAKE) -e test; \
|
||||
fi
|
||||
@TEST_OUTPUT=$$(cd $(BUILD_PATH) && ./test | head -c 12); \
|
||||
if [ $$TEST_OUTPUT = $(TEST_EXPECTED) ]; then \
|
||||
echo "test succeeded."; \
|
||||
else \
|
||||
echo "test failed, expected:" $(TEST_EXPECTED) "but got:" $(TEST_OUTPUT); \
|
||||
echo "test failed, expected:" $(TEST_EXPECTED) "but got:" $$TEST_OUTPUT; \
|
||||
fi
|
||||
tidy:
|
||||
go mod tidy
|
||||
|
@ -3,11 +3,13 @@
|
||||
#include "libcomandy.h"
|
||||
|
||||
int main() {
|
||||
puts(request("{\"method\":\"GET\","
|
||||
char* para = "{\"method\":\"GET\","
|
||||
"\"url\":\"https://i.pximg.net/img-master/img/2012/04/04/21/24/46/26339586_p0_master1200.jpg\","
|
||||
"\"headers\":{"
|
||||
"\"Referer\":\"https://www.pixiv.net/\","
|
||||
"\"User-Agent\":\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36 Edg/123.0.0.0\""
|
||||
"}"
|
||||
"}"));
|
||||
"}";
|
||||
fputs(para, stderr); fputs("\n", stderr);
|
||||
puts(request(para));
|
||||
}
|
||||
|
12
dns.go
12
dns.go
@ -72,8 +72,8 @@ func (ds *dnsservers) dial(ctx context.Context) (tlsConn *tls.Conn, err error) {
|
||||
addr.E = false // no need to acquire write lock
|
||||
continue
|
||||
}
|
||||
tlsConn = terasu.Use(tls.Client(conn, &tls.Config{ServerName: host}))
|
||||
err = tlsConn.HandshakeContext(ctx)
|
||||
tlsConn = tls.Client(conn, &tls.Config{ServerName: host})
|
||||
err = terasu.Use(tlsConn).HandshakeContext(ctx)
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
@ -86,10 +86,6 @@ func (ds *dnsservers) dial(ctx context.Context) (tlsConn *tls.Conn, err error) {
|
||||
|
||||
var dotv6servers = dnsservers{
|
||||
m: map[string][]*dnsstat{
|
||||
"dns.alidns.com": {
|
||||
{"[2400:3200::1]:853", true},
|
||||
{"[2400:3200:baba::1]:853", true},
|
||||
},
|
||||
"dot.sb": {
|
||||
{"[2a09::]:853", true},
|
||||
{"[2a11::]:853", true},
|
||||
@ -115,10 +111,6 @@ var dotv6servers = dnsservers{
|
||||
|
||||
var dotv4servers = dnsservers{
|
||||
m: map[string][]*dnsstat{
|
||||
"dns.alidns.com": {
|
||||
{"223.5.5.5:853", true},
|
||||
{"223.6.6.6:853", true},
|
||||
},
|
||||
"dot.sb": {
|
||||
{"185.222.222.222:853", true},
|
||||
{"45.11.45.11:853", true},
|
||||
|
16
dns_test.go
16
dns_test.go
@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"net"
|
||||
"testing"
|
||||
|
||||
@ -20,12 +21,12 @@ func TestResolver(t *testing.T) {
|
||||
|
||||
func TestDNS(t *testing.T) {
|
||||
if canUseIPv6.Get() {
|
||||
dotv6servers.test(t)
|
||||
dotv6servers.test()
|
||||
}
|
||||
dotv4servers.test(t)
|
||||
dotv4servers.test()
|
||||
}
|
||||
|
||||
func (ds *dnsservers) test(t *testing.T) {
|
||||
func (ds *dnsservers) test() {
|
||||
ds.RLock()
|
||||
defer ds.RUnlock()
|
||||
for host, addrs := range ds.m {
|
||||
@ -33,18 +34,19 @@ func (ds *dnsservers) test(t *testing.T) {
|
||||
if !addr.E {
|
||||
continue
|
||||
}
|
||||
fmt.Println("dial:", host, addr.A)
|
||||
conn, err := net.Dial("tcp", addr.A)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
tlsConn := terasu.Use(tls.Client(conn, &tls.Config{ServerName: host}))
|
||||
err = tlsConn.Handshake()
|
||||
tlsConn := tls.Client(conn, &tls.Config{ServerName: host})
|
||||
err = terasu.Use(tlsConn).Handshake()
|
||||
_ = tlsConn.Close()
|
||||
if err == nil {
|
||||
t.Log("succ:", host, addr.A)
|
||||
fmt.Println("succ:", host, addr.A)
|
||||
continue
|
||||
}
|
||||
t.Fatal("fail:", host, addr.A)
|
||||
fmt.Println("fail:", host, addr.A)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
2
go.mod
2
go.mod
@ -5,7 +5,7 @@ go 1.22.1
|
||||
require (
|
||||
github.com/FloatTech/ttl v0.0.0-20230307105452-d6f7b2b647d1
|
||||
github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e
|
||||
github.com/fumiama/terasu v0.0.0-20240415131749-e65650a52c3c
|
||||
github.com/fumiama/terasu v0.0.0-20240416061047-62d3c9f6be80
|
||||
golang.org/x/net v0.24.0
|
||||
)
|
||||
|
||||
|
4
go.sum
4
go.sum
@ -4,8 +4,8 @@ github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e h1:wR3MXQ3VbUlPKOOU
|
||||
github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e/go.mod h1:vD7Ra3Q9onRtojoY5sMCLQ7JBgjUsrXDnDKyFxqpf9w=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/fumiama/terasu v0.0.0-20240415131749-e65650a52c3c h1:RxkHkeanPDrZrEEcUcosgBULmL8UDkSasvwP+jpdIZQ=
|
||||
github.com/fumiama/terasu v0.0.0-20240415131749-e65650a52c3c/go.mod h1:BFl0X1+rGJf8bLHl/kO+v05ryHrj/R4kyCrK89NvegA=
|
||||
github.com/fumiama/terasu v0.0.0-20240416061047-62d3c9f6be80 h1:O1JJZzcd5ggUw/9X8V9KxBZ9JZGWFmX/r1q2TPg+pZQ=
|
||||
github.com/fumiama/terasu v0.0.0-20240416061047-62d3c9f6be80/go.mod h1:BFl0X1+rGJf8bLHl/kO+v05ryHrj/R4kyCrK89NvegA=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
|
||||
|
13
http.go
13
http.go
@ -69,8 +69,8 @@ var cli = comandyClient(http.Client{
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
tlsConn = terasu.Use(tls.Client(conn, cfg))
|
||||
err = tlsConn.HandshakeContext(ctx)
|
||||
tlsConn = tls.Client(conn, cfg)
|
||||
err = terasu.Use(tlsConn).HandshakeContext(ctx)
|
||||
if err == nil {
|
||||
break
|
||||
}
|
||||
@ -105,8 +105,14 @@ func (r *capsule) printstrerr(err string) string {
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
func (cli *comandyClient) request(para string) string {
|
||||
func (cli *comandyClient) request(para string) (ret string) {
|
||||
r := capsule{}
|
||||
defer func() {
|
||||
err := recover()
|
||||
if err != nil {
|
||||
ret = r.printstrerr(fmt.Sprint())
|
||||
}
|
||||
}()
|
||||
wg := sync.WaitGroup{}
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
@ -147,7 +153,6 @@ func (cli *comandyClient) request(para string) string {
|
||||
return r.printstrerr("unsupported H type " + reflect.ValueOf(x).Type().Name())
|
||||
}
|
||||
}
|
||||
fmt.Println(r.U)
|
||||
wg.Wait()
|
||||
resp, err := (*http.Client)(cli).Do(req)
|
||||
if err != nil {
|
||||
|
@ -28,8 +28,10 @@ func TestClientGet(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(data) == 0 {
|
||||
t.Fail()
|
||||
}
|
||||
t.Log(bytesToString(data))
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
func TestRequest(t *testing.T) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user