Skip to content

Commit

Permalink
attempt to fix this bug YouROK#1
Browse files Browse the repository at this point in the history
  • Loading branch information
trinity-aml committed Jun 5, 2024
1 parent ee00b05 commit 4958dc0
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 9 deletions.
17 changes: 10 additions & 7 deletions build-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ OUTPUT="${ROOT}/dist/numParser"
#### Build server
echo "Build"
BUILD_FLAGS="-ldflags=${LDFLAGS}"
rm -f dist/*
rm -f dist/numParser-*

#####################################
### X86 build section
Expand All @@ -69,9 +69,9 @@ for PLATFORM in "${PLATFORMS[@]}"; do
CMD="GOOS=${GOOS} GOARCH=${GOARCH} ${GO_ARM} ${GO_MIPS} CGO_ENABLED=0 ${GOBIN} build ${BUILD_FLAGS} -o ${BIN_FILENAME} ./cmd"
echo "${CMD}"
eval "$CMD" || FAILURES="${FAILURES} ${GOOS}/${GOARCH}${GOARM}"
# CMD="../upx -q ${BIN_FILENAME}"; # upx --brute produce much smaller binaries
# echo "compress with ${CMD}"
# eval "$CMD"
CMD="./upx -q ${BIN_FILENAME}"; # upx --brute produce much smaller binaries
echo "compress with ${CMD}"
eval "$CMD"
done

#####################################
Expand Down Expand Up @@ -101,9 +101,9 @@ for V in "${COMPILERS[@]}"; do
CMD="GOOS=${GOOS} GOARCH=${GOARCH} ${GO_ARM} CGO_ENABLED=1 ${GOBIN} build ${BUILD_FLAGS} -o ${BIN_FILENAME} ./cmd"
echo "${CMD}"
eval "${CMD}" || FAILURES="${FAILURES} ${GOOS}/${GOARCH}${GOARM}"
# CMD="../upx -q ${BIN_FILENAME}"; # upx --brute produce much smaller binaries
# echo "compress with ${CMD}"
# eval "$CMD"
CMD="./upx -q ${BIN_FILENAME}"; # upx --brute produce much smaller binaries
echo "compress with ${CMD}"
eval "$CMD"
done

#####################################
Expand All @@ -117,6 +117,9 @@ BIN_FILENAME="${OUTPUT}-${GOOS}-amd64-nogui.exe"
CMD="GOOS=${GOOS} GOARCH=${GOARCH} CGO_ENABLED=0 ${GOBIN} build ${BUILD_FLAGS} -o ${BIN_FILENAME} ./cmd"
echo "${CMD}"
eval "$CMD" || FAILURES="${FAILURES} windows/amd64 NOGUI"
CMD="./upx -q ${BIN_FILENAME}"; # upx --brute produce much smaller binaries
echo "compress with ${CMD}"
eval "$CMD"

# eval errors
if [[ "${FAILURES}" != "" ]]; then
Expand Down
49 changes: 49 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ import (
"NUMParser/releases"
"NUMParser/version"
"NUMParser/web"
"context"
"fmt"
"github.com/alexflint/go-arg"
"github.com/jasonlvhit/gocron"
"log"
"net"
"net/url"
"os"
"os/exec"
Expand Down Expand Up @@ -77,6 +79,8 @@ func main() {
}
}

dnsResolve()

db.Init()
loadProxy()
tmdb.Init()
Expand All @@ -95,6 +99,51 @@ func main() {

}

func dnsResolve() {
hosts := [6]string{"1.1.1.1", "1.0.0.1", "208.67.222.222", "208.67.220.220", "8.8.8.8", "8.8.4.4"}
ret := 0
for _, ip := range hosts {
ret = toolResolve("www.google.com", ip)
switch {
case ret == 2:
fmt.Println("DNS resolver OK\n")
case ret == 1:
fmt.Println("New DNS resolver OK\n")
case ret == 0:
fmt.Println("New DNS resolver failed\n")
}
if ret == 2 || ret == 1 {
break
}
}
}

func toolResolve(host string, serverDNS string) int {
addrs, err := net.LookupHost(host)
addr_dns := fmt.Sprintf("%s:53", serverDNS)
a := 0
if len(addrs) == 0 {
fmt.Println("Check dns", addrs, err)
fn := func(ctx context.Context, network, address string) (net.Conn, error) {
d := net.Dialer{}
return d.DialContext(ctx, "udp", addr_dns)
}
net.DefaultResolver = &net.Resolver{
Dial: fn,
}
addrs, err = net.LookupHost(host)
fmt.Println("Check new dns", addrs, err)
if err == nil || len(addrs) > 0 {
a = 1
} else {
a = 0
}
} else {
a = 2
}
return a
}

func scanReleases() {
loadProxy()
getDbInfo()
Expand Down
4 changes: 3 additions & 1 deletion parser/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ func get(link string) (string, error) {
var body string
var err error
for i := 0; i < 10; i++ {
if strings.Contains(link, "\t") {
link = strings.Replace(link, "\t", "", -1)
}
if strings.Contains(link, "rutor.lib") {
body, err = client.GetNic(link, "", "")
} else {
Expand All @@ -25,7 +28,6 @@ func get(link string) (string, error) {
if err == nil || err == client.Err404 {
break
}

log.Println("Error get page,tryes:", i+1, link, err)
if i < 5 {
time.Sleep(time.Minute)
Expand Down
Binary file added upx
Binary file not shown.
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package version

const Version = "1.5"
const Version = "1.6"

0 comments on commit 4958dc0

Please sign in to comment.