mirror of
https://github.com/Snawoot/hola-proxy.git
synced 2026-04-04 21:28:17 +00:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
683bc5f1ec | ||
|
|
be2e4e5420 | ||
|
|
95adb40377 | ||
|
|
6ced446e68 | ||
|
|
9c15f5eda9 | ||
|
|
afe3e3f732 | ||
|
|
e67b30a116 | ||
|
|
edc367f194 | ||
|
|
ed77f8a254 | ||
|
|
45977423f6 | ||
|
|
64c90af10b | ||
|
|
c3180ad245 | ||
|
|
0052dea171 |
18
Makefile
18
Makefile
@@ -54,3 +54,21 @@ $(OUTSUFFIX).windows-386.exe: $(src)
|
||||
|
||||
clean:
|
||||
rm -f bin/*
|
||||
|
||||
fmt:
|
||||
go fmt ./...
|
||||
|
||||
run:
|
||||
go run .
|
||||
|
||||
.PHONY: clean all native fmt \
|
||||
bin-native \
|
||||
bin-linux-amd64 \
|
||||
bin-linux-386 \
|
||||
bin-linux-arm \
|
||||
bin-freebsd-amd64 \
|
||||
bin-freebsd-386 \
|
||||
bin-freebsd-arm \
|
||||
bin-darwin-amd64 \
|
||||
bin-windows-amd64 \
|
||||
bin-windows-386
|
||||
|
||||
@@ -154,7 +154,9 @@ Usage of /home/user/go/bin/hola-proxy:
|
||||
-country string
|
||||
desired proxy location (default "us")
|
||||
-dont-use-trial
|
||||
use regular ports instead of trial ports (default true)
|
||||
use regular ports instead of trial ports
|
||||
-force-port-field string
|
||||
force specific port field/num (example 24232 or lum)
|
||||
-limit uint
|
||||
amount of proxies in retrieved list (default 3)
|
||||
-list-countries
|
||||
|
||||
26
holaapi.go
26
holaapi.go
@@ -5,6 +5,8 @@ import (
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/campoy/unique"
|
||||
"github.com/google/uuid"
|
||||
"io/ioutil"
|
||||
@@ -24,12 +26,17 @@ const BG_INIT_URL = CCGI_URL + "background_init"
|
||||
const ZGETTUNNELS_URL = CCGI_URL + "zgettunnels"
|
||||
const LOGIN_PREFIX = "user-uuid-"
|
||||
|
||||
var TemporaryBanError = errors.New("temporary ban detected")
|
||||
var PermanentBanError = errors.New("permanent ban detected")
|
||||
|
||||
type CountryList []string
|
||||
|
||||
type BgInitResponse struct {
|
||||
Ver string `json:"ver"`
|
||||
Key int64 `json:"key"`
|
||||
Country string `json:"country"`
|
||||
Ver string `json:"ver"`
|
||||
Key int64 `json:"key"`
|
||||
Country string `json:"country"`
|
||||
Blocked bool `json:"blocked,omitempty"`
|
||||
Permanent bool `json:"permanent,omitempty"`
|
||||
}
|
||||
|
||||
type PortMap struct {
|
||||
@@ -81,6 +88,11 @@ func do_req(ctx context.Context, method, url string, query, data url.Values) ([]
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch resp.StatusCode {
|
||||
case http.StatusOK, http.StatusCreated, http.StatusAccepted, http.StatusNoContent:
|
||||
default:
|
||||
return nil, errors.New(fmt.Sprintf("Bad HTTP response: %d %s", resp.StatusCode, resp.Status))
|
||||
}
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
resp.Body.Close()
|
||||
if err != nil {
|
||||
@@ -118,7 +130,15 @@ func background_init(ctx context.Context, user_uuid string) (res BgInitResponse,
|
||||
reterr = err
|
||||
return
|
||||
}
|
||||
|
||||
reterr = json.Unmarshal(resp, &res)
|
||||
if reterr == nil && res.Blocked {
|
||||
if res.Permanent {
|
||||
reterr = PermanentBanError
|
||||
} else {
|
||||
reterr = TemporaryBanError
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
2
main.go
2
main.go
@@ -63,7 +63,7 @@ func parse_args() CLIArgs {
|
||||
flag.StringVar(&args.resolver, "resolver", "https://cloudflare-dns.com/dns-query",
|
||||
"DNS/DoH/DoT resolver to workaround Hola blocked hosts. "+
|
||||
"See https://github.com/ameshkov/dnslookup/ for upstream DNS URL format.")
|
||||
flag.BoolVar(&args.use_trial, "dont-use-trial", true, "use regular ports instead of trial ports") // would be nice to not show in help page
|
||||
flag.BoolVar(&args.use_trial, "dont-use-trial", false, "use regular ports instead of trial ports") // would be nice to not show in help page
|
||||
flag.Parse()
|
||||
if args.country == "" {
|
||||
arg_fail("Country can't be empty string.")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
name: hola-proxy
|
||||
version: '1.4.0'
|
||||
version: '1.4.2'
|
||||
summary: Standalone Hola proxy client.
|
||||
description: |
|
||||
Standalone Hola proxy client. Just run it and it'll start plain HTTP proxy server forwarding traffic via Hola proxies of your choice.
|
||||
|
||||
4
utils.go
4
utils.go
@@ -116,13 +116,13 @@ func get_endpoint(tunnels *ZGetTunnelsResponse, typ string, trial bool, force_po
|
||||
}
|
||||
if typ != "skip" {
|
||||
if typ == "direct" || typ == "lum" || typ == "pool" || typ == "virt" {
|
||||
if trial {
|
||||
if !trial {
|
||||
port = tunnels.Port.Trial
|
||||
} else {
|
||||
port = tunnels.Port.Direct
|
||||
}
|
||||
} else if typ == "peer" {
|
||||
if trial {
|
||||
if !trial {
|
||||
port = tunnels.Port.TrialPeer
|
||||
} else {
|
||||
port = tunnels.Port.Peer
|
||||
|
||||
Reference in New Issue
Block a user