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
|
- name: Build Libraries
|
||||||
env:
|
env:
|
||||||
NDK_TOOLCHAIN: ${{ steps.setup-ndk.outputs.ndk-path }}
|
NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
|
||||||
BUILD_MACHINE: linux
|
BUILD_MACHINE: linux
|
||||||
run: |
|
run: |
|
||||||
echo NDK path is $NDK_TOOLCHAIN
|
echo NDK path is $NDK_HOME
|
||||||
make -e
|
make -e
|
||||||
|
|
||||||
- name: Upload Binaries to Release
|
- 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
|
- name: Test Build
|
||||||
env:
|
env:
|
||||||
NDK_TOOLCHAIN: ${{ steps.setup-ndk.outputs.ndk-path }}
|
NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
|
||||||
BUILD_MACHINE: linux
|
BUILD_MACHINE: linux
|
||||||
run: |
|
run: |
|
||||||
echo NDK path is $NDK_TOOLCHAIN
|
echo NDK path is $NDK_HOME
|
||||||
ls $NDK_TOOLCHAIN
|
ls $NDK_HOME
|
||||||
make -e
|
make -e
|
||||||
|
|
||||||
- name: Build and Run Tests
|
- name: Build and Run Tests
|
||||||
env:
|
env:
|
||||||
NDK_TOOLCHAIN: ${{ steps.setup-ndk.outputs.ndk-path }}
|
NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
|
||||||
BUILD_MACHINE: linux
|
BUILD_MACHINE: linux
|
||||||
GOARCH: amd64
|
GOARCH: amd64
|
||||||
run: make -e runtest
|
run: make -e runtest
|
||||||
|
18
Makefile
18
Makefile
@ -13,12 +13,12 @@ TARGET_ARCH := aarch64 # optional: armv7a i686 x86_64
|
|||||||
|
|
||||||
CGO_ENABLED := 1
|
CGO_ENABLED := 1
|
||||||
GO_SRC := $(shell find . -name '*.go' | grep -v '_test.go$$')
|
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
|
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)/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)/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
|
@BUILD_PATH=$(BUILD_PATH)/i686 TARGET_ARCH=i686 GOARCH=amd64 $(MAKE) -e shared
|
||||||
@ -32,11 +32,15 @@ shared: $(GO_SRC) dir tidy
|
|||||||
test: dir
|
test: dir
|
||||||
@GOOS=$(BUILD_MACHINE) CC=cc NDK_TOOLCHAIN="" $(MAKE) -e shared
|
@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)
|
cc -o $(BUILD_PATH)/test $(BUILD_PATH)/test.c -l$(PROJECT_NAME) -L$(BUILD_PATH)
|
||||||
runtest: test
|
runtest:
|
||||||
@if [ $(TEST_OUTPUT) = $(TEST_EXPECTED) ]; then \
|
@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."; \
|
echo "test succeeded."; \
|
||||||
else \
|
else \
|
||||||
echo "test failed, expected:" $(TEST_EXPECTED) "but got:" $(TEST_OUTPUT); \
|
echo "test failed, expected:" $(TEST_EXPECTED) "but got:" $$TEST_OUTPUT; \
|
||||||
fi
|
fi
|
||||||
tidy:
|
tidy:
|
||||||
go mod tidy
|
go mod tidy
|
||||||
|
@ -3,11 +3,13 @@
|
|||||||
#include "libcomandy.h"
|
#include "libcomandy.h"
|
||||||
|
|
||||||
int main() {
|
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\","
|
"\"url\":\"https://i.pximg.net/img-master/img/2012/04/04/21/24/46/26339586_p0_master1200.jpg\","
|
||||||
"\"headers\":{"
|
"\"headers\":{"
|
||||||
"\"Referer\":\"https://www.pixiv.net/\","
|
"\"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\""
|
"\"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
|
addr.E = false // no need to acquire write lock
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
tlsConn = terasu.Use(tls.Client(conn, &tls.Config{ServerName: host}))
|
tlsConn = tls.Client(conn, &tls.Config{ServerName: host})
|
||||||
err = tlsConn.HandshakeContext(ctx)
|
err = terasu.Use(tlsConn).HandshakeContext(ctx)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -86,10 +86,6 @@ func (ds *dnsservers) dial(ctx context.Context) (tlsConn *tls.Conn, err error) {
|
|||||||
|
|
||||||
var dotv6servers = dnsservers{
|
var dotv6servers = dnsservers{
|
||||||
m: map[string][]*dnsstat{
|
m: map[string][]*dnsstat{
|
||||||
"dns.alidns.com": {
|
|
||||||
{"[2400:3200::1]:853", true},
|
|
||||||
{"[2400:3200:baba::1]:853", true},
|
|
||||||
},
|
|
||||||
"dot.sb": {
|
"dot.sb": {
|
||||||
{"[2a09::]:853", true},
|
{"[2a09::]:853", true},
|
||||||
{"[2a11::]:853", true},
|
{"[2a11::]:853", true},
|
||||||
@ -115,10 +111,6 @@ var dotv6servers = dnsservers{
|
|||||||
|
|
||||||
var dotv4servers = dnsservers{
|
var dotv4servers = dnsservers{
|
||||||
m: map[string][]*dnsstat{
|
m: map[string][]*dnsstat{
|
||||||
"dns.alidns.com": {
|
|
||||||
{"223.5.5.5:853", true},
|
|
||||||
{"223.6.6.6:853", true},
|
|
||||||
},
|
|
||||||
"dot.sb": {
|
"dot.sb": {
|
||||||
{"185.222.222.222:853", true},
|
{"185.222.222.222:853", true},
|
||||||
{"45.11.45.11:853", true},
|
{"45.11.45.11:853", true},
|
||||||
|
16
dns_test.go
16
dns_test.go
@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -20,12 +21,12 @@ func TestResolver(t *testing.T) {
|
|||||||
|
|
||||||
func TestDNS(t *testing.T) {
|
func TestDNS(t *testing.T) {
|
||||||
if canUseIPv6.Get() {
|
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()
|
ds.RLock()
|
||||||
defer ds.RUnlock()
|
defer ds.RUnlock()
|
||||||
for host, addrs := range ds.m {
|
for host, addrs := range ds.m {
|
||||||
@ -33,18 +34,19 @@ func (ds *dnsservers) test(t *testing.T) {
|
|||||||
if !addr.E {
|
if !addr.E {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
fmt.Println("dial:", host, addr.A)
|
||||||
conn, err := net.Dial("tcp", addr.A)
|
conn, err := net.Dial("tcp", addr.A)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
tlsConn := terasu.Use(tls.Client(conn, &tls.Config{ServerName: host}))
|
tlsConn := tls.Client(conn, &tls.Config{ServerName: host})
|
||||||
err = tlsConn.Handshake()
|
err = terasu.Use(tlsConn).Handshake()
|
||||||
_ = tlsConn.Close()
|
_ = tlsConn.Close()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Log("succ:", host, addr.A)
|
fmt.Println("succ:", host, addr.A)
|
||||||
continue
|
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 (
|
require (
|
||||||
github.com/FloatTech/ttl v0.0.0-20230307105452-d6f7b2b647d1
|
github.com/FloatTech/ttl v0.0.0-20230307105452-d6f7b2b647d1
|
||||||
github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e
|
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
|
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/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 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
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-20240416061047-62d3c9f6be80 h1:O1JJZzcd5ggUw/9X8V9KxBZ9JZGWFmX/r1q2TPg+pZQ=
|
||||||
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/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 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
|
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 {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
tlsConn = terasu.Use(tls.Client(conn, cfg))
|
tlsConn = tls.Client(conn, cfg)
|
||||||
err = tlsConn.HandshakeContext(ctx)
|
err = terasu.Use(tlsConn).HandshakeContext(ctx)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -105,8 +105,14 @@ func (r *capsule) printstrerr(err string) string {
|
|||||||
return buf.String()
|
return buf.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cli *comandyClient) request(para string) string {
|
func (cli *comandyClient) request(para string) (ret string) {
|
||||||
r := capsule{}
|
r := capsule{}
|
||||||
|
defer func() {
|
||||||
|
err := recover()
|
||||||
|
if err != nil {
|
||||||
|
ret = r.printstrerr(fmt.Sprint())
|
||||||
|
}
|
||||||
|
}()
|
||||||
wg := sync.WaitGroup{}
|
wg := sync.WaitGroup{}
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
@ -147,7 +153,6 @@ func (cli *comandyClient) request(para string) string {
|
|||||||
return r.printstrerr("unsupported H type " + reflect.ValueOf(x).Type().Name())
|
return r.printstrerr("unsupported H type " + reflect.ValueOf(x).Type().Name())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fmt.Println(r.U)
|
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
resp, err := (*http.Client)(cli).Do(req)
|
resp, err := (*http.Client)(cli).Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -28,8 +28,10 @@ func TestClientGet(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
t.Log(bytesToString(data))
|
if len(data) == 0 {
|
||||||
t.Fail()
|
t.Fail()
|
||||||
|
}
|
||||||
|
t.Log(bytesToString(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRequest(t *testing.T) {
|
func TestRequest(t *testing.T) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user