Compare commits

...

7 Commits

Author SHA1 Message Date
Snawoot
ff3c0f68fc Merge pull request #29 from Snawoot/versioning
embed version into binary
2021-03-13 04:35:35 +02:00
Vladislav Yarmak
4f72e317fc embed version into local install and local run as well 2021-03-13 04:34:24 +02:00
Vladislav Yarmak
4ddd1284fb embed version into binary 2021-03-13 04:23:36 +02:00
Snawoot
4fe6636003 Merge pull request #27 from rany2/master
Don't repeat response code twice
2021-03-13 00:06:37 +02:00
Snawoot
b5ac6d38e5 Merge pull request #28 from Snawoot/fix_status_log
fix status logging on hola api error
2021-03-13 00:05:44 +02:00
Vladislav Yarmak
0c377308c0 fix status logging on hola api error 2021-03-13 00:04:57 +02:00
rany
3b21036b20 Don't repeat response code twice 2021-03-12 23:28:35 +02:00
4 changed files with 19 additions and 5 deletions

View File

@@ -1,7 +1,8 @@
PROGNAME = hola-proxy
OUTSUFFIX = bin/$(PROGNAME)
VERSION := $(shell git describe)
BUILDOPTS = -a -tags netgo
LDFLAGS = -ldflags '-s -w -extldflags "-static"'
LDFLAGS = -ldflags '-s -w -extldflags "-static" -X main.version=$(VERSION)'
src = $(wildcard *.go)
@@ -59,9 +60,12 @@ fmt:
go fmt ./...
run:
go run .
go run $(LDFLAGS) .
.PHONY: clean all native fmt \
install:
go install $(BUILDOPTS) $(LDFLAGS) .
.PHONY: clean all native fmt install \
bin-native \
bin-linux-amd64 \
bin-linux-386 \

View File

@@ -44,7 +44,7 @@ Pre-built binaries available on [releases](https://github.com/Snawoot/hola-proxy
Alternatively, you may install hola-proxy from source. Run within source directory
```
go install
make install
```
#### Docker

View File

@@ -91,7 +91,7 @@ func do_req(ctx context.Context, method, url string, query, data url.Values) ([]
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))
return nil, errors.New(fmt.Sprintf("Bad HTTP response: %s", resp.Status))
}
body, err := ioutil.ReadAll(resp.Body)
resp.Body.Close()

10
main.go
View File

@@ -13,6 +13,7 @@ import (
var (
PROTOCOL_WHITELIST map[string]bool
version = "undefined"
)
func init() {
@@ -44,6 +45,7 @@ type CLIArgs struct {
proxy_type string
resolver string
force_port_field string
showVersion bool
}
func parse_args() CLIArgs {
@@ -64,6 +66,7 @@ func parse_args() CLIArgs {
"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", false, "use regular ports instead of trial ports") // would be nice to not show in help page
flag.BoolVar(&args.showVersion, "version", false, "show program version and exit")
flag.Parse()
if args.country == "" {
arg_fail("Country can't be empty string.")
@@ -79,6 +82,11 @@ func parse_args() CLIArgs {
func run() int {
args := parse_args()
if args.showVersion {
fmt.Println(version)
return 0
}
if args.list_countries {
return print_countries(args.timeout)
}
@@ -98,6 +106,7 @@ func run() int {
proxyLogger := NewCondLogger(log.New(logWriter, "PROXY : ",
log.LstdFlags|log.Lshortfile),
args.verbosity)
mainLogger.Info("hola-proxy client version %s is starting...", version)
mainLogger.Info("Constructing fallback DNS upstream...")
resolver, err := NewResolver(args.resolver, args.timeout)
if err != nil {
@@ -120,6 +129,7 @@ func run() int {
mainLogger.Info("Endpoint: %s", endpoint)
mainLogger.Info("Starting proxy server...")
handler := NewProxyHandler(endpoint, auth, resolver, proxyLogger)
mainLogger.Info("Init complete.")
err = http.ListenAndServe(args.bind_address, handler)
mainLogger.Critical("Server terminated with a reason: %v", err)
mainLogger.Info("Shutting down...")