Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '>1.23.1'
go-version: '>1.24.0'

- name: Test
run: go test -v ./...
8 changes: 4 additions & 4 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ jobs:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install Go
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
with:
go-version: 1.23.x
go-version: 1.24.x
- name: Lint
uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6.1.1
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
with:
args: --verbose
version: v1.62.0
version: v2.1.6
67 changes: 41 additions & 26 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,47 @@
version: "2"
linters:
enable:
- depguard
- goimports
- misspell
- revive

issues:
exclude-rules:
- path: _test.go
linters:
- errcheck

linters-settings:
depguard:
rules:
no_exec_policy:
files:
- "!$test"
deny:
- pkg: "os/exec"
desc: "Using os/exec to run sub processes it not allowed by policy"
errcheck:
exclude-functions:
# Used in HTTP handlers, any error is handled by the server itself.
- (net/http.ResponseWriter).Write
revive:
settings:
depguard:
rules:
no_exec_policy:
files:
- '!$test'
deny:
- pkg: os/exec
desc: Using os/exec to run sub processes it not allowed by policy
errcheck:
exclude-functions:
- (net/http.ResponseWriter).Write
revive:
rules:
- name: unused-parameter
severity: warning
disabled: true
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-parameter
- name: unused-parameter
severity: warning
disabled: true
- linters:
- errcheck
path: _test.go
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
- goimports
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
14 changes: 10 additions & 4 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ before:

builds:
- id: "403unlockercli-linux" # Unique ID for this build
main: ./cmd/403unlockercli
main: ./cmd
binary: "403unlocker"
env:
- CGO_ENABLED=0
Expand All @@ -15,19 +15,23 @@ builds:
goarch:
- amd64
- arm64
ldflags:
- -X 403unlocker-cli/cmd/cli.Version={{ .Version }}

- id: "403unlockercli-windows" # Unique ID for this build
main: ./cmd/403unlockercli
main: ./cmd
binary: "403unlocker"
env:
- CGO_ENABLED=0
goos:
- windows
goarch:
- amd64
ldflags:
- -X 403unlocker-cli/cmd/cli.Version={{ .Version }}

- id: "403unlockercli-darwin" # Unique ID for this build
main: ./cmd/403unlockercli
main: ./cmd
binary: "403unlocker"
env:
- CGO_ENABLED=0
Expand All @@ -36,6 +40,8 @@ builds:
goarch:
- amd64
- arm64
ldflags:
- -X 403unlocker-cli/cmd/cli.Version={{ .Version }}

archives:
- format: tar.gz
Expand Down Expand Up @@ -65,4 +71,4 @@ release:

---

Released by [GoReleaser](https://github.com/goreleaser/goreleaser).
Released by [GoReleaser](https://github.com/goreleaser/goreleaser).
18 changes: 9 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

OUTPUT = 403unlocker
MAIN = cmd/403unlockercli/main.go
MAIN = cmd/main.go
BIN_DIR = ~/.local/bin
CONFIG_DIR= ~/.config/403unlocker
DNS_CONFIG_FILE_URL=https://raw.githubusercontent.com/403unlocker/403Unlocker-cli/refs/heads/main/config/dns.conf
DOCKER_CONFIG_FILE_URL=https://raw.githubusercontent.com/403unlocker/403Unlocker-cli/refs/heads/main/config/dockerRegistry.conf
DNS_CONFIG_FILE_URL=https://raw.githubusercontent.com/403unlocker/403Unlocker-cli/refs/heads/main/config/dns.yml
DOCKER_CONFIG_FILE_URL=https://raw.githubusercontent.com/403unlocker/403Unlocker-cli/refs/heads/main/config/dockerRegistry.yml

.DEFAULT_GOAL := help

Expand All @@ -23,23 +23,23 @@ lint:


build:
@go build -o $(OUTPUT) $(MAIN)
@go build -ldflags "-X 403unlocker-cli/cmd/cli.Version=dev" -o $(OUTPUT) $(MAIN)


test:
test:
@go test ./...


clean:
clean:
@rm -f $(OUTPUT)


install: build
install: build
@echo "Installing $(OUTPUT) to $(BIN_DIR)..."
@install -m 755 $(OUTPUT) $(BIN_DIR)
@echo "Downloading config files dns.conf to $(CONFIG_DIR)..."
@echo "Downloading config files dns.yml to $(CONFIG_DIR)..."
@wget $(DNS_CONFIG_FILE_URL) -q -P $(CONFIG_DIR)
@echo "Downloading dockerRegistry.conf $(CONFIG_DIR)..."
@echo "Downloading dockerRegistry.yml $(CONFIG_DIR)..."
@wget $(DOCKER_CONFIG_FILE_URL) -q -P $(CONFIG_DIR)


Expand Down
7 changes: 0 additions & 7 deletions cmd/403unlockercli/main.go

This file was deleted.

41 changes: 41 additions & 0 deletions cmd/cli/bestdns.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package cli

import (
"403unlocker-cli/internal/dns"
"fmt"

"github.com/spf13/cobra"
)

var (
timeoutBestDns int
checkfirst bool
)

var bestdnsCmd = &cobra.Command{
Use: "bestdns",
Short: "Finds the fastest DNS SNI-Proxy for downloading a specific URL",
Long: `Finds the fastest DNS SNI-Proxy for downloading a specific URL

Examples:
403unlocker bestdns --timeout 15 https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/7/gitlab-ce-16.8.0-ce.0.el7.x86_64.rpm/download.rpm`,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
if !dns.URLValidator(args[0]) {
fmt.Println("Error: Invalid URL")
return cmd.Help()
}
return dns.CheckWithURL(args[0], checkfirst, timeoutBestDns)
},
Aliases: []string{"dns"},
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return []string{}, cobra.ShellCompDirectiveNoFileComp
},
}

func init() {
bestdnsCmd.PersistentFlags().IntVarP(&timeoutBestDns, "timeout", "t", 10, "Sets timeout")
bestdnsCmd.PersistentFlags().BoolVarP(&checkfirst, "check", "c", false, "first check with GET to route '/' of domain ")

rootCmd.AddCommand(bestdnsCmd)
}
32 changes: 32 additions & 0 deletions cmd/cli/check.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package cli

import (
"403unlocker-cli/internal/check"

"github.com/spf13/cobra"
)

var checkCmd = &cobra.Command{
Use: "check",
Short: "Checks if the DNS SNI-Proxy can bypass 403 error for a specific domain",
Long: `Checks if the DNS SNI-Proxy can bypass 403 error for a specific domain

Examples:
403unlocker check https://pkg.go.dev`,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
if !check.DomainValidator(args[0]) {
cmd.Printf("Error: '%s' is not a valid domain format\n\n", args[0])
return cmd.Help()
}
return check.CheckWithDNS(args[0])
},
Aliases: []string{"c"},
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return []string{}, cobra.ShellCompDirectiveNoFileComp
},
}

func init() {
rootCmd.AddCommand(checkCmd)
}
38 changes: 38 additions & 0 deletions cmd/cli/fastdocker.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package cli

import (
"403unlocker-cli/internal/docker"

"github.com/spf13/cobra"
)

var (
timeoutFastDocker int
)

var fastdockerCmd = &cobra.Command{
Use: "fastdocker",
Short: "Finds the fastest docker registries for a specific docker image",
Long: `Examples:
403unlocker fastdocker --timeout 15 gitlab/gitlab-ce:17.0.0-ce.0`,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
if docker.DockerImageValidator(args[0]) {
return docker.CheckWithDockerImage(args[0], timeoutFastDocker)
} else {
cmd.Printf("Error: '%s' is not a valid docker image format\n\n", args[0])
return cmd.Help()
}
},
Aliases: []string{"docker"},
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return []string{}, cobra.ShellCompDirectiveNoFileComp
},
}

func init() {
fastdockerCmd.PersistentFlags().IntVarP(&timeoutFastDocker, "timeout", "t", 10, "Sets timeout")

rootCmd.AddCommand(fastdockerCmd)

}
26 changes: 26 additions & 0 deletions cmd/cli/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package cli

import (
"os"

"github.com/spf13/cobra"
)

var Version = "dev" // <- Injected by ldflags

var rootCmd = &cobra.Command{
Use: "403unlocker",
Short: "403Unlocker-CLI is a versatile command-line tool designed to bypass 403 restrictions effectively",
Long: `403Unlocker-CLI is a versatile command-line tool designed to bypass 403 restrictions effectively`,
Version: Version, // Enables --version flag
}

func Execute() {
err := rootCmd.Execute()
if err != nil {
os.Exit(1)
}
}

func init() {
}
10 changes: 10 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package main

import (
"403unlocker-cli/cmd/cli"
)

func main() {
cli.Execute()

}
1 change: 0 additions & 1 deletion config/dns.conf

This file was deleted.

20 changes: 20 additions & 0 deletions config/dns.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
dnsServers:
- 178.22.122.100
- 185.51.200.2
- 192.104.158.78
- 194.104.158.48
- 172.29.0.100
- 172.29.2.100
- 10.202.10.202
- 10.202.10.102
- 185.55.226.26
- 185.55.225.25
- 10.202.10.10
- 10.202.10.11
- 37.27.41.228
- 87.107.52.11
- 87.107.52.13
- 5.202.100.100
- 5.202.100.101
- 94.103.125.157
- 94.103.125.158
1 change: 0 additions & 1 deletion config/dockerRegistry.conf

This file was deleted.

9 changes: 9 additions & 0 deletions config/dockerRegistry.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
registryList:
- "docker.arvancloud.ir"
- "focker.ir"
- "registry.docker.ir"
- "docker.host:5000"
- "docker.iranserver.com"
- "docker.haiocloud.com"
- "registry.registryhub.ir"
- "docker-mirror.kubarcloud.com"
Loading