mirror of
https://github.com/Snawoot/hola-proxy.git
synced 2026-04-05 11:28:15 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
56a10f2a32 | ||
|
|
801178a7de | ||
|
|
6d627de3d7 |
1
.dockerignore
Normal file
1
.dockerignore
Normal file
@@ -0,0 +1 @@
|
||||
bin/
|
||||
14
Dockerfile
Normal file
14
Dockerfile
Normal file
@@ -0,0 +1,14 @@
|
||||
FROM golang AS build
|
||||
|
||||
WORKDIR /go/src/github.com/Snawoot/hola-proxy
|
||||
COPY . .
|
||||
RUN CGO_ENABLED=0 go build -a -tags netgo -ldflags '-s -w -extldflags "-static"'
|
||||
ADD https://curl.haxx.se/ca/cacert.pem /certs.crt
|
||||
RUN chmod 0644 /certs.crt
|
||||
|
||||
FROM scratch
|
||||
COPY --from=build /go/src/github.com/Snawoot/hola-proxy/hola-proxy /
|
||||
COPY --from=build /certs.crt /etc/ssl/certs/ca-certificates.crt
|
||||
USER 9999:9999
|
||||
EXPOSE 8080/tcp
|
||||
ENTRYPOINT ["/hola-proxy", "-bind-address", "0.0.0.0:8080"]
|
||||
11
README.md
11
README.md
@@ -20,6 +20,17 @@ Alternatively, you may install hola-proxy from source. Run within source directo
|
||||
go install
|
||||
```
|
||||
|
||||
Docker image is available as well. Here is an example for running proxy via DE as a background service:
|
||||
|
||||
```sh
|
||||
docker run -d \
|
||||
--security-opt no-new-privileges \
|
||||
-p 127.0.0.1:8080:8080 \
|
||||
--restart unless-stopped \
|
||||
--name hola-proxy \
|
||||
yarmak/hola-proxy -country de
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
List available countries:
|
||||
|
||||
19
main.go
19
main.go
@@ -71,13 +71,13 @@ func parse_args() CLIArgs {
|
||||
return args
|
||||
}
|
||||
|
||||
func main() {
|
||||
func run() int {
|
||||
args := parse_args()
|
||||
if args.list_countries {
|
||||
os.Exit(print_countries(args.timeout))
|
||||
return print_countries(args.timeout)
|
||||
}
|
||||
if args.list_proxies {
|
||||
os.Exit(print_proxies(args.country, args.limit, args.timeout))
|
||||
return print_proxies(args.country, args.limit, args.timeout)
|
||||
}
|
||||
|
||||
logWriter := NewLogWriter(os.Stderr)
|
||||
@@ -96,22 +96,29 @@ func main() {
|
||||
resolver, err := NewResolver(args.resolver, args.timeout)
|
||||
if err != nil {
|
||||
mainLogger.Critical("Unable to instantiate DNS resolver: %v", err)
|
||||
os.Exit(6)
|
||||
return 6
|
||||
}
|
||||
mainLogger.Info("Initializing configuration provider...")
|
||||
auth, tunnels, err := CredService(args.rotate, args.timeout, args.country, credLogger)
|
||||
if err != nil {
|
||||
mainLogger.Critical("Unable to instantiate credential service: %v", err)
|
||||
os.Exit(4)
|
||||
logWriter.Close()
|
||||
return 4
|
||||
}
|
||||
endpoint, err := get_endpoint(tunnels, args.proxy_type)
|
||||
if err != nil {
|
||||
mainLogger.Critical("Unable to determine proxy endpoint: %v", err)
|
||||
os.Exit(5)
|
||||
logWriter.Close()
|
||||
return 5
|
||||
}
|
||||
mainLogger.Info("Starting proxy server...")
|
||||
handler := NewProxyHandler(endpoint, auth, resolver, proxyLogger)
|
||||
err = http.ListenAndServe(args.bind_address, handler)
|
||||
mainLogger.Critical("Server terminated with a reason: %v", err)
|
||||
mainLogger.Info("Shutting down...")
|
||||
return 0
|
||||
}
|
||||
|
||||
func main() {
|
||||
os.Exit(run())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user