Compare commits

...

5 Commits

Author SHA1 Message Date
Quentin McGaw
6fc2b3dd21 Mullvad servers do not have a default port
- Refers to #218
- Checks for custom port value depending on protocol
- Remove default port from server constants
- Use 443 and 1194 ports respectively for tcp and udp
2020-08-24 01:53:24 +00:00
hyness
7e3e6f166a Add new PIA servers hostnames to resolver tool (#222)
Refers to #216
2020-08-20 19:20:59 -04:00
Quentin McGaw
c614a192a4 Shadowsocks in Go (#220), fixes #211 2020-08-20 19:19:54 -04:00
Quentin McGaw
b10a476622 Default status file base directory /tmp/gluetun 2020-08-18 01:08:24 +00:00
Quentin McGaw
15ddbdefef Bump versions and binary build changes
- Go version 1.15
- Golangci-lint 1.30
- Trim path of binary built
2020-08-17 20:39:49 -04:00
19 changed files with 600 additions and 798 deletions

View File

@@ -45,6 +45,3 @@ run:
- .devcontainer - .devcontainer
- .github - .github
- postgres - postgres
service:
golangci-lint-version: 1.27.x # use the fixed version to not introduce new linters unexpectedly

View File

@@ -1,10 +1,10 @@
ARG ALPINE_VERSION=3.12 ARG ALPINE_VERSION=3.12
ARG GO_VERSION=1.14 ARG GO_VERSION=1.15
FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS builder FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS builder
RUN apk --update add git RUN apk --update add git
ENV CGO_ENABLED=0 ENV CGO_ENABLED=0
ARG GOLANGCI_LINT_VERSION=v1.27.0 ARG GOLANGCI_LINT_VERSION=v1.30.0
RUN wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s ${GOLANGCI_LINT_VERSION} RUN wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s ${GOLANGCI_LINT_VERSION}
WORKDIR /tmp/gobuild WORKDIR /tmp/gobuild
COPY .golangci.yml . COPY .golangci.yml .
@@ -14,7 +14,7 @@ COPY cmd/gluetun/main.go .
COPY internal/ ./internal/ COPY internal/ ./internal/
RUN go test ./... RUN go test ./...
RUN golangci-lint run --timeout=10m RUN golangci-lint run --timeout=10m
RUN go build -ldflags="-s -w" -o entrypoint main.go RUN go build -trimpath -ldflags="-s -w" -o entrypoint main.go
FROM alpine:${ALPINE_VERSION} FROM alpine:${ALPINE_VERSION}
ARG VERSION ARG VERSION
@@ -41,7 +41,7 @@ ENV VPNSP=pia \
TZ= \ TZ= \
UID=1000 \ UID=1000 \
GID=1000 \ GID=1000 \
IP_STATUS_FILE="/ip" \ IP_STATUS_FILE="/tmp/gluetun/ip" \
# PIA, Windscribe, Surfshark, Cyberghost, Vyprvpn, NordVPN, PureVPN only # PIA, Windscribe, Surfshark, Cyberghost, Vyprvpn, NordVPN, PureVPN only
USER= \ USER= \
PASSWORD= \ PASSWORD= \
@@ -49,7 +49,7 @@ ENV VPNSP=pia \
# PIA only # PIA only
PIA_ENCRYPTION=strong \ PIA_ENCRYPTION=strong \
PORT_FORWARDING=off \ PORT_FORWARDING=off \
PORT_FORWARDING_STATUS_FILE="/forwarded_port" \ PORT_FORWARDING_STATUS_FILE="/tmp/gluetun/forwarded_port" \
# Mullvad and PureVPN only # Mullvad and PureVPN only
COUNTRY= \ COUNTRY= \
CITY= \ CITY= \
@@ -101,8 +101,6 @@ ENTRYPOINT ["/entrypoint"]
EXPOSE 8000/tcp 8888/tcp 8388/tcp 8388/udp EXPOSE 8000/tcp 8888/tcp 8388/tcp 8388/udp
HEALTHCHECK --interval=10m --timeout=10s --start-period=30s --retries=2 CMD /entrypoint healthcheck HEALTHCHECK --interval=10m --timeout=10s --start-period=30s --retries=2 CMD /entrypoint healthcheck
RUN apk add -q --progress --no-cache --update openvpn ca-certificates iptables ip6tables unbound tinyproxy tzdata && \ RUN apk add -q --progress --no-cache --update openvpn ca-certificates iptables ip6tables unbound tinyproxy tzdata && \
echo "http://nl.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories && \
apk add -q --progress --no-cache --update shadowsocks-libev && \
rm -rf /var/cache/apk/* /etc/unbound/* /usr/sbin/unbound-* /etc/tinyproxy/tinyproxy.conf && \ rm -rf /var/cache/apk/* /etc/unbound/* /usr/sbin/unbound-* /etc/tinyproxy/tinyproxy.conf && \
deluser openvpn && \ deluser openvpn && \
deluser tinyproxy && \ deluser tinyproxy && \

View File

@@ -91,7 +91,7 @@ Want more testing? ▶ [see the Wiki](https://github.com/qdm12/gluetun/wiki/Test
| Variable | Default | Choices | Description | | Variable | Default | Choices | Description |
| --- | --- | --- | --- | | --- | --- | --- | --- |
| 🏁 `VPNSP` | `private internet access` | `private internet access`, `mullvad`, `windscribe`, `surfshark`, `vyprvpn`, `nordvpn`, `purevpn` | VPN Service Provider | | 🏁 `VPNSP` | `private internet access` | `private internet access`, `mullvad`, `windscribe`, `surfshark`, `vyprvpn`, `nordvpn`, `purevpn` | VPN Service Provider |
| `IP_STATUS_FILE` | `/ip` | Any filepath | Filepath to store the public IP address assigned | | `IP_STATUS_FILE` | `/tmp/gluetun/ip` | Any filepath | Filepath to store the public IP address assigned |
| `PROTOCOL` | `udp` | `udp` or `tcp` | Network protocol to use | | `PROTOCOL` | `udp` | `udp` or `tcp` | Network protocol to use |
| `OPENVPN_VERBOSITY` | `1` | `0` to `6` | Openvpn verbosity level | | `OPENVPN_VERBOSITY` | `1` | `0` to `6` | Openvpn verbosity level |
| `OPENVPN_ROOT` | `no` | `yes` or `no` | Run OpenVPN as root | | `OPENVPN_ROOT` | `no` | `yes` or `no` | Run OpenVPN as root |
@@ -110,7 +110,7 @@ Want more testing? ▶ [see the Wiki](https://github.com/qdm12/gluetun/wiki/Test
| `REGION` | | One of the [PIA regions](https://www.privateinternetaccess.com/pages/network/) | VPN server region | | `REGION` | | One of the [PIA regions](https://www.privateinternetaccess.com/pages/network/) | VPN server region |
| `PIA_ENCRYPTION` | `strong` | `normal`, `strong` | Encryption preset | | `PIA_ENCRYPTION` | `strong` | `normal`, `strong` | Encryption preset |
| `PORT_FORWARDING` | `off` | `on`, `off` | Enable port forwarding on the VPN server | | `PORT_FORWARDING` | `off` | `on`, `off` | Enable port forwarding on the VPN server |
| `PORT_FORWARDING_STATUS_FILE` | `/forwarded_port` | Any filepath | Filepath to store the forwarded port number | | `PORT_FORWARDING_STATUS_FILE` | `/tmp/gluetun/forwarded_port` | Any filepath | Filepath to store the forwarded port number |
- Mullvad - Mullvad
@@ -120,7 +120,7 @@ Want more testing? ▶ [see the Wiki](https://github.com/qdm12/gluetun/wiki/Test
| `COUNTRY` | | One of the [Mullvad countries](https://mullvad.net/en/servers/#openvpn) | VPN server country | | `COUNTRY` | | One of the [Mullvad countries](https://mullvad.net/en/servers/#openvpn) | VPN server country |
| `CITY` | | One of the [Mullvad cities](https://mullvad.net/en/servers/#openvpn) | VPN server city | | `CITY` | | One of the [Mullvad cities](https://mullvad.net/en/servers/#openvpn) | VPN server city |
| `ISP` | | One of the [Mullvad ISP](https://mullvad.net/en/servers/#openvpn) | VPN server ISP | | `ISP` | | One of the [Mullvad ISP](https://mullvad.net/en/servers/#openvpn) | VPN server ISP |
| `PORT` | | `80` or `443` for TCP; or `53` for UDP. Leave blank for default Mullvad server port | Custom VPN port to use | | `PORT` | | `80`, `443` or `1401` for TCP; `53`, `1194`, `1195`, `1196`, `1197`, `1300`, `1301`, `1302`, `1303` or `1400` for UDP. Defaults to TCP `443` and UDP `1194` | Custom VPN port to use |
- Windscribe - Windscribe
@@ -227,7 +227,7 @@ That one is important if you want to connect to the container from your LAN for
| `SHADOWSOCKS_LOG` | `off` | `on`, `off` | Enable logging | | `SHADOWSOCKS_LOG` | `off` | `on`, `off` | Enable logging |
| `SHADOWSOCKS_PORT` | `8388` | `1024` to `65535` | Internal port number for Shadowsocks to listen on | | `SHADOWSOCKS_PORT` | `8388` | `1024` to `65535` | Internal port number for Shadowsocks to listen on |
| `SHADOWSOCKS_PASSWORD` | | | Password to use to connect to Shadowsocks | | `SHADOWSOCKS_PASSWORD` | | | Password to use to connect to Shadowsocks |
| `SHADOWSOCKS_METHOD` | `chacha20-ietf-poly1305` | One of [these ciphers](https://shadowsocks.org/en/config/quick-guide.html) | Method to use for Shadowsocks | | `SHADOWSOCKS_METHOD` | `chacha20-ietf-poly1305` | `chacha20-ietf-poly1305`, `aes-128-gcm`, `aes-256-gcm` | Method to use for Shadowsocks |
### Tinyproxy ### Tinyproxy

View File

@@ -69,7 +69,6 @@ func _main(background context.Context, args []string) int {
routingConf := routing.NewRouting(logger, fileManager) routingConf := routing.NewRouting(logger, fileManager)
firewallConf := firewall.NewConfigurator(logger, routingConf, fileManager) firewallConf := firewall.NewConfigurator(logger, routingConf, fileManager)
tinyProxyConf := tinyproxy.NewConfigurator(fileManager, logger) tinyProxyConf := tinyproxy.NewConfigurator(fileManager, logger)
shadowsocksConf := shadowsocks.NewConfigurator(fileManager, logger)
streamMerger := command.NewStreamMerger() streamMerger := command.NewStreamMerger()
paramsReader := params.NewReader(logger, fileManager) paramsReader := params.NewReader(logger, fileManager)
@@ -79,11 +78,10 @@ func _main(background context.Context, args []string) int {
paramsReader.GetBuildDate())) paramsReader.GetBuildDate()))
printVersions(ctx, logger, map[string]func(ctx context.Context) (string, error){ printVersions(ctx, logger, map[string]func(ctx context.Context) (string, error){
"OpenVPN": ovpnConf.Version, "OpenVPN": ovpnConf.Version,
"Unbound": dnsConf.Version, "Unbound": dnsConf.Version,
"IPtables": firewallConf.Version, "IPtables": firewallConf.Version,
"TinyProxy": tinyProxyConf.Version, "TinyProxy": tinyProxyConf.Version,
"ShadowSocks": shadowsocksConf.Version,
}) })
allSettings, err := settings.GetAllSettings(paramsReader) allSettings, err := settings.GetAllSettings(paramsReader)
@@ -170,7 +168,7 @@ func _main(background context.Context, args []string) int {
restartTinyproxy := tinyproxyLooper.Restart restartTinyproxy := tinyproxyLooper.Restart
go tinyproxyLooper.Run(ctx, wg) go tinyproxyLooper.Run(ctx, wg)
shadowsocksLooper := shadowsocks.NewLooper(shadowsocksConf, firewallConf, allSettings.ShadowSocks, allSettings.DNS, logger, streamMerger, uid, gid, defaultInterface) shadowsocksLooper := shadowsocks.NewLooper(firewallConf, allSettings.ShadowSocks, logger, defaultInterface)
restartShadowsocks := shadowsocksLooper.Restart restartShadowsocks := shadowsocksLooper.Restart
go shadowsocksLooper.Run(ctx, wg) go shadowsocksLooper.Run(ctx, wg)

View File

@@ -31,6 +31,9 @@ func _main(ctx context.Context) int {
case "pia": case "pia":
domain = "privateinternetaccess.com" domain = "privateinternetaccess.com"
servers = piaServers() servers = piaServers()
case "pia-nextgen":
domain = "privacy.network"
servers = piaNextgenServers()
case "windscribe": case "windscribe":
domain = "windscribe.com" domain = "windscribe.com"
servers = windscribeServers() servers = windscribeServers()
@@ -263,6 +266,54 @@ func piaServers() []server {
} }
} }
func piaNextgenServers() []server {
return []server{
{subdomain: "aus-melbourne", region: "AU Melbourne"},
{subdomain: "aus-perth", region: "AU Perth"},
{subdomain: "au-sydney", region: "AU Sydney"},
{subdomain: "austria", region: "Austria"},
{subdomain: "brussels", region: "Belgium"},
{subdomain: "ca-montreal", region: "CA Montreal"},
{subdomain: "ca-toronto", region: "CA Toronto"},
{subdomain: "czech", region: "Czech Republic"},
{subdomain: "de-berlin", region: "DE Berlin"},
{subdomain: "de-frankfurt", region: "DE Frankfurt"},
{subdomain: "denmark", region: "Denmark"},
{subdomain: "fi", region: "Finland"},
{subdomain: "france", region: "France"},
{subdomain: "hungary", region: "Hungary"},
{subdomain: "in", region: "India"},
{subdomain: "ireland", region: "Ireland"},
{subdomain: "israel", region: "Israel"},
{subdomain: "italy", region: "Italy"},
{subdomain: "japan", region: "Japan"},
{subdomain: "lu", region: "Luxembourg"},
{subdomain: "mexico", region: "Mexico"},
{subdomain: "nl-amsterdam", region: "Netherlands"},
{subdomain: "nz", region: "New Zealand"},
{subdomain: "no", region: "Norway"},
{subdomain: "poland", region: "Poland"},
{subdomain: "ro", region: "Romania"},
{subdomain: "sg", region: "Singapore"},
{subdomain: "spain", region: "Spain"},
{subdomain: "sweden", region: "Sweden"},
{subdomain: "swiss", region: "Switzerland"},
{subdomain: "ae", region: "UAE"},
{subdomain: "uk-london", region: "UK London"},
{subdomain: "uk-manchester", region: "UK Manchester"},
{subdomain: "us-atlanta", region: "US Atlanta"},
{subdomain: "us-california", region: "US California"},
{subdomain: "us-chicago", region: "US Chicago"},
{subdomain: "us-denver", region: "US Denver"},
{subdomain: "us-florida", region: "US Florida"},
{subdomain: "us-houston", region: "US Houston"},
{subdomain: "us-seattle", region: "US Seattle"},
{subdomain: "us-siliconvalley", region: "US Silicon Valley"},
{subdomain: "us-washingtondc", region: "US Washington DC"},
{subdomain: "us3", region: "US West"},
}
}
func windscribeServers() []server { func windscribeServers() []server {
return []server{ return []server{
{subdomain: "al", region: "Albania"}, {subdomain: "al", region: "Albania"},

7
go.mod
View File

@@ -1,12 +1,13 @@
module github.com/qdm12/gluetun module github.com/qdm12/gluetun
go 1.14 go 1.15
require ( require (
github.com/fatih/color v1.9.0 github.com/fatih/color v1.9.0
github.com/golang/mock v1.4.3 github.com/golang/mock v1.4.4
github.com/kyokomi/emoji v2.2.4+incompatible github.com/kyokomi/emoji v2.2.4+incompatible
github.com/qdm12/golibs v0.0.0-20200712151944-a0325873bf5a github.com/qdm12/golibs v0.0.0-20200712151944-a0325873bf5a
github.com/qdm12/ss-server v0.0.0-20200819005413-6b516c299307
github.com/stretchr/testify v1.6.1 github.com/stretchr/testify v1.6.1
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed
) )

12
go.sum
View File

@@ -39,6 +39,8 @@ github.com/go-openapi/validate v0.17.0 h1:pqoViQz3YLOGIhAmD0N4Lt6pa/3Gnj3ymKqQwq
github.com/go-openapi/validate v0.17.0/go.mod h1:Uh4HdOzKt19xGIGm1qHf/ofbX1YQ4Y+MYsct2VUrAJ4= github.com/go-openapi/validate v0.17.0/go.mod h1:Uh4HdOzKt19xGIGm1qHf/ofbX1YQ4Y+MYsct2VUrAJ4=
github.com/golang/mock v1.4.3 h1:GV+pQPG/EUUbkh47niozDcADz6go/dUwhVzdUQHIVRw= github.com/golang/mock v1.4.3 h1:GV+pQPG/EUUbkh47niozDcADz6go/dUwhVzdUQHIVRw=
github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
github.com/golang/mock v1.4.4 h1:l75CXGRSwbaYNpl/Z2X1XIIAMSCquvXgpVZDhwEIJsc=
github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4= github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
@@ -72,6 +74,10 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/qdm12/golibs v0.0.0-20200712151944-a0325873bf5a h1:IyS72qFm+iXipadmUKXmpJScKXXK2GrD8yYfxXsnIYs= github.com/qdm12/golibs v0.0.0-20200712151944-a0325873bf5a h1:IyS72qFm+iXipadmUKXmpJScKXXK2GrD8yYfxXsnIYs=
github.com/qdm12/golibs v0.0.0-20200712151944-a0325873bf5a/go.mod h1:pikkTN7g7zRuuAnERwqW1yAFq6pYmxrxpjiwGvb0Ysc= github.com/qdm12/golibs v0.0.0-20200712151944-a0325873bf5a/go.mod h1:pikkTN7g7zRuuAnERwqW1yAFq6pYmxrxpjiwGvb0Ysc=
github.com/qdm12/ss-server v0.0.0-20200819005413-6b516c299307 h1:+LhVxIKpZgUM8ZcopIuc3Yjk+p76dWRdYLQiAA7caZM=
github.com/qdm12/ss-server v0.0.0-20200819005413-6b516c299307/go.mod h1:ABVUkxubboL3vqBkOwDV9glX1/x7SnYrckBe5d+M/zw=
github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg=
github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
@@ -92,6 +98,8 @@ go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200117160349-530e935923ad/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200117160349-530e935923ad/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de h1:ikNHVSjEfnvz6sxdSPCaPt572qowuyMDMJLLm3Db3ig=
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs= golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs=
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
@@ -106,8 +114,8 @@ golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI= golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae h1:Ih9Yo4hSPImZOpfGuA4bR/ORKTAbhZo2AbWNRCnevdo= golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed h1:J22ig1FUekjjkmZUM7pTKixYm8DvrYsvrBZdunYeIuQ=
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

View File

@@ -56,604 +56,520 @@ func MullvadISPChoices() (choices []string) {
func MullvadServers() []models.MullvadServer { func MullvadServers() []models.MullvadServer {
return []models.MullvadServer{ return []models.MullvadServer{
{ {
Country: "united arab emirates", Country: "united arab emirates",
City: "dubai", City: "dubai",
ISP: "m247", ISP: "m247",
IPs: []net.IP{{45, 9, 249, 34}}, IPs: []net.IP{{45, 9, 249, 34}},
DefaultPort: 1194,
}, },
{ {
Country: "albania", Country: "albania",
City: "tirana", City: "tirana",
ISP: "iregister", ISP: "iregister",
IPs: []net.IP{{31, 171, 154, 210}}, IPs: []net.IP{{31, 171, 154, 210}},
DefaultPort: 1197,
}, },
{ {
Country: "austria", Country: "austria",
City: "wien", City: "wien",
ISP: "m247", ISP: "m247",
IPs: []net.IP{{37, 120, 155, 250}, {217, 64, 127, 138}, {217, 64, 127, 202}}, IPs: []net.IP{{37, 120, 155, 250}, {217, 64, 127, 138}, {217, 64, 127, 202}},
DefaultPort: 1196,
}, },
{ {
Country: "australia", Country: "australia",
City: "adelaide", City: "adelaide",
ISP: "intergrid", ISP: "intergrid",
IPs: []net.IP{{116, 206, 231, 58}}, IPs: []net.IP{{116, 206, 231, 58}},
DefaultPort: 1300,
}, },
{ {
Country: "australia", Country: "australia",
City: "brisbane", City: "brisbane",
ISP: "intergrid", ISP: "intergrid",
IPs: []net.IP{{43, 245, 160, 162}}, IPs: []net.IP{{43, 245, 160, 162}},
DefaultPort: 1300,
}, },
{ {
Country: "australia", Country: "australia",
City: "canberra", City: "canberra",
ISP: "intergrid", ISP: "intergrid",
IPs: []net.IP{{116, 206, 229, 98}}, IPs: []net.IP{{116, 206, 229, 98}},
DefaultPort: 1300,
}, },
{ {
Country: "australia", Country: "australia",
City: "melbourne", City: "melbourne",
ISP: "intergrid", ISP: "intergrid",
IPs: []net.IP{{116, 206, 228, 202}, {116, 206, 228, 242}, {116, 206, 230, 98}}, IPs: []net.IP{{116, 206, 228, 202}, {116, 206, 228, 242}, {116, 206, 230, 98}},
DefaultPort: 1300,
}, },
{ {
Country: "australia", Country: "australia",
City: "perth", City: "perth",
ISP: "intergrid", ISP: "intergrid",
IPs: []net.IP{{103, 77, 235, 66}}, IPs: []net.IP{{103, 77, 235, 66}},
DefaultPort: 1300,
}, },
{ {
Country: "australia", Country: "australia",
City: "sydney", City: "sydney",
ISP: "intergrid", ISP: "intergrid",
IPs: []net.IP{{43, 245, 162, 130}, {103, 77, 232, 130}, {103, 77, 232, 146}}, IPs: []net.IP{{43, 245, 162, 130}, {103, 77, 232, 130}, {103, 77, 232, 146}},
DefaultPort: 1300,
}, },
{ {
Country: "australia", Country: "australia",
City: "sydney", City: "sydney",
ISP: "m247", ISP: "m247",
IPs: []net.IP{{217, 138, 204, 82}, {217, 138, 204, 98}, {217, 138, 204, 66}}, IPs: []net.IP{{217, 138, 204, 82}, {217, 138, 204, 98}, {217, 138, 204, 66}},
DefaultPort: 1300,
}, },
{ {
Country: "belgium", Country: "belgium",
City: "brussels", City: "brussels",
ISP: "m247", ISP: "m247",
IPs: []net.IP{{37, 120, 218, 146}, {37, 120, 218, 138}, {91, 207, 57, 50}, {37, 120, 143, 138}, {185, 104, 186, 202}}, IPs: []net.IP{{37, 120, 218, 146}, {37, 120, 218, 138}, {91, 207, 57, 50}, {37, 120, 143, 138}, {185, 104, 186, 202}},
DefaultPort: 1300,
}, },
{ {
Country: "bulgaria", Country: "bulgaria",
City: "sofia", City: "sofia",
ISP: "m247", ISP: "m247",
IPs: []net.IP{{185, 94, 192, 42}, {185, 94, 192, 66}}, IPs: []net.IP{{185, 94, 192, 42}, {185, 94, 192, 66}},
DefaultPort: 1300,
}, },
{ {
Country: "brazil", Country: "brazil",
City: "sao paulo", City: "sao paulo",
ISP: "qnax", ISP: "qnax",
IPs: []net.IP{{191, 101, 62, 178}}, IPs: []net.IP{{191, 101, 62, 178}},
DefaultPort: 1301,
}, },
{ {
Country: "brazil", Country: "brazil",
City: "sao paulo", City: "sao paulo",
ISP: "heficed", ISP: "heficed",
IPs: []net.IP{{177, 67, 80, 186}}, IPs: []net.IP{{177, 67, 80, 186}},
DefaultPort: 1300,
}, },
{ {
Country: "canada", Country: "canada",
City: "montreal", City: "montreal",
ISP: "m247", ISP: "m247",
IPs: []net.IP{{139, 28, 218, 114}, {217, 138, 200, 194}, {217, 138, 200, 186}, {87, 101, 92, 146}, {176, 113, 74, 178}, {37, 120, 205, 114}, {87, 101, 92, 138}, {37, 120, 205, 122}, {217, 138, 200, 210}, {217, 138, 200, 202}}, IPs: []net.IP{{139, 28, 218, 114}, {217, 138, 200, 194}, {217, 138, 200, 186}, {87, 101, 92, 146}, {176, 113, 74, 178}, {37, 120, 205, 114}, {87, 101, 92, 138}, {37, 120, 205, 122}, {217, 138, 200, 210}, {217, 138, 200, 202}},
DefaultPort: 1300,
}, },
{ {
Country: "canada", Country: "canada",
City: "toronto", City: "toronto",
ISP: "amanah", ISP: "amanah",
IPs: []net.IP{{184, 75, 214, 130}, {162, 219, 176, 250}}, IPs: []net.IP{{184, 75, 214, 130}, {162, 219, 176, 250}},
DefaultPort: 1300,
}, },
{ {
Country: "canada", Country: "canada",
City: "vancouver", City: "vancouver",
ISP: "100tb", ISP: "100tb",
IPs: []net.IP{{172, 83, 40, 34}, {172, 83, 40, 38}}, IPs: []net.IP{{172, 83, 40, 34}, {172, 83, 40, 38}},
DefaultPort: 1300,
}, },
{ {
Country: "canada", Country: "canada",
City: "vancouver", City: "vancouver",
ISP: "esecuredata", ISP: "esecuredata",
IPs: []net.IP{{71, 19, 249, 81}, {176, 113, 74, 186}, {71, 19, 248, 240}}, IPs: []net.IP{{71, 19, 249, 81}, {176, 113, 74, 186}, {71, 19, 248, 240}},
DefaultPort: 1300,
}, },
{ {
Country: "switzerland", Country: "switzerland",
City: "zurich", City: "zurich",
ISP: "31173", ISP: "31173",
IPs: []net.IP{{193, 32, 127, 82}, {193, 32, 127, 81}, {193, 32, 127, 83}, {193, 32, 127, 84}}, IPs: []net.IP{{193, 32, 127, 82}, {193, 32, 127, 81}, {193, 32, 127, 83}, {193, 32, 127, 84}},
Owned: true, Owned: true,
DefaultPort: 1301,
}, },
{ {
Country: "zwitzerland", Country: "zwitzerland",
City: "zurich", City: "zurich",
ISP: "m247", ISP: "m247",
IPs: []net.IP{{185, 212, 170, 50}, {185, 183, 104, 82}, {185, 9, 18, 98}, {82, 102, 24, 130}, {82, 102, 24, 186}, {185, 212, 170, 162}, {185, 9, 18, 114}}, IPs: []net.IP{{185, 212, 170, 50}, {185, 183, 104, 82}, {185, 9, 18, 98}, {82, 102, 24, 130}, {82, 102, 24, 186}, {185, 212, 170, 162}, {185, 9, 18, 114}},
DefaultPort: 1301,
}, },
{ {
Country: "switzerland", Country: "switzerland",
City: "zurich", City: "zurich",
ISP: "privateLayer", ISP: "privateLayer",
IPs: []net.IP{{179, 43, 128, 170}, {81, 17, 20, 34}}, IPs: []net.IP{{179, 43, 128, 170}, {81, 17, 20, 34}},
DefaultPort: 1301,
}, },
{ {
Country: "czech republic", Country: "czech republic",
City: "prague", City: "prague",
ISP: "m247", ISP: "m247",
IPs: []net.IP{{217, 138, 199, 82}, {217, 138, 199, 74}}, IPs: []net.IP{{217, 138, 199, 82}, {217, 138, 199, 74}},
DefaultPort: 1197,
}, },
{ {
Country: "germany", Country: "germany",
City: "frankfurt", City: "frankfurt",
ISP: "31173", ISP: "31173",
IPs: []net.IP{{185, 213, 155, 132}, {185, 213, 155, 140}, {185, 213, 155, 136}, {185, 213, 155, 133}, {185, 213, 155, 144}, {185, 213, 155, 143}, {185, 213, 155, 138}, {185, 213, 155, 142}, {185, 213, 155, 139}, {185, 213, 155, 135}, {185, 213, 155, 145}, {185, 213, 155, 137}, {185, 213, 155, 131}, {185, 213, 155, 134}, {185, 213, 155, 141}}, IPs: []net.IP{{185, 213, 155, 132}, {185, 213, 155, 140}, {185, 213, 155, 136}, {185, 213, 155, 133}, {185, 213, 155, 144}, {185, 213, 155, 143}, {185, 213, 155, 138}, {185, 213, 155, 142}, {185, 213, 155, 139}, {185, 213, 155, 135}, {185, 213, 155, 145}, {185, 213, 155, 137}, {185, 213, 155, 131}, {185, 213, 155, 134}, {185, 213, 155, 141}},
Owned: true, Owned: true,
DefaultPort: 1197,
}, },
{ {
Country: "germany", Country: "germany",
City: "frankfurt", City: "frankfurt",
ISP: "m247", ISP: "m247",
IPs: []net.IP{{82, 102, 16, 90}, {185, 104, 184, 186}, {77, 243, 183, 202}}, IPs: []net.IP{{82, 102, 16, 90}, {185, 104, 184, 186}, {77, 243, 183, 202}},
DefaultPort: 1197,
}, },
{ {
Country: "denmark", Country: "denmark",
City: "copenhagen", City: "copenhagen",
ISP: "31173", ISP: "31173",
IPs: []net.IP{{141, 98, 254, 71}, {141, 98, 254, 72}}, IPs: []net.IP{{141, 98, 254, 71}, {141, 98, 254, 72}},
Owned: true, Owned: true,
DefaultPort: 1195,
}, },
{ {
Country: "denmark", Country: "denmark",
City: "copenhagen", City: "copenhagen",
ISP: "m247", ISP: "m247",
IPs: []net.IP{{185, 206, 224, 114}, {185, 206, 224, 119}}, IPs: []net.IP{{185, 206, 224, 114}, {185, 206, 224, 119}},
DefaultPort: 1195,
}, },
{ {
Country: "denmark", Country: "denmark",
City: "copenhagen", City: "copenhagen",
ISP: "blix", ISP: "blix",
IPs: []net.IP{{134, 90, 149, 138}}, IPs: []net.IP{{134, 90, 149, 138}},
DefaultPort: 1195,
}, },
{ {
Country: "denmark", Country: "denmark",
City: "copenhagen", City: "copenhagen",
ISP: "asergo", ISP: "asergo",
IPs: []net.IP{{82, 103, 140, 213}}, IPs: []net.IP{{82, 103, 140, 213}},
DefaultPort: 1195,
}, },
{ {
Country: "spain", Country: "spain",
City: "madrid", City: "madrid",
ISP: "m247", ISP: "m247",
IPs: []net.IP{{195, 206, 107, 146}, {45, 152, 183, 42}, {89, 238, 178, 74}, {45, 152, 183, 26}, {89, 238, 178, 34}}, IPs: []net.IP{{195, 206, 107, 146}, {45, 152, 183, 42}, {89, 238, 178, 74}, {45, 152, 183, 26}, {89, 238, 178, 34}},
DefaultPort: 1195,
}, },
{ {
Country: "finland", Country: "finland",
City: "helsinki", City: "helsinki",
ISP: "creanova", ISP: "creanova",
IPs: []net.IP{{185, 204, 1, 174}, {185, 204, 1, 176}, {185, 212, 149, 201}, {185, 204, 1, 175}, {185, 204, 1, 173}, {185, 204, 1, 172}, {185, 204, 1, 171}}, IPs: []net.IP{{185, 204, 1, 174}, {185, 204, 1, 176}, {185, 212, 149, 201}, {185, 204, 1, 175}, {185, 204, 1, 173}, {185, 204, 1, 172}, {185, 204, 1, 171}},
Owned: true, Owned: true,
DefaultPort: 1196,
}, },
{ {
Country: "france", Country: "france",
City: "paris", City: "paris",
ISP: "31173", ISP: "31173",
IPs: []net.IP{{193, 32, 126, 83}, {193, 32, 126, 82}, {193, 32, 126, 81}, {193, 32, 126, 84}}, IPs: []net.IP{{193, 32, 126, 83}, {193, 32, 126, 82}, {193, 32, 126, 81}, {193, 32, 126, 84}},
Owned: true, Owned: true,
DefaultPort: 1301,
}, },
{ {
Country: "france", Country: "france",
City: "paris", City: "paris",
ISP: "m247", ISP: "m247",
IPs: []net.IP{{185, 189, 113, 82}, {185, 156, 173, 218}, {185, 128, 25, 162}}, IPs: []net.IP{{185, 189, 113, 82}, {185, 156, 173, 218}, {185, 128, 25, 162}},
DefaultPort: 1301,
}, },
{ {
Country: "uk", Country: "uk",
City: "london", City: "london",
ISP: "31173", ISP: "31173",
IPs: []net.IP{{141, 98, 252, 133}, {141, 98, 252, 139}, {141, 98, 252, 137}, {141, 98, 252, 143}, {141, 98, 252, 142}, {141, 98, 252, 132}, {141, 98, 252, 134}, {141, 98, 252, 140}, {141, 98, 252, 141}, {141, 98, 252, 136}, {141, 98, 252, 144}, {141, 98, 252, 131}, {141, 98, 252, 135}, {141, 98, 252, 138}}, IPs: []net.IP{{141, 98, 252, 133}, {141, 98, 252, 139}, {141, 98, 252, 137}, {141, 98, 252, 143}, {141, 98, 252, 142}, {141, 98, 252, 132}, {141, 98, 252, 134}, {141, 98, 252, 140}, {141, 98, 252, 141}, {141, 98, 252, 136}, {141, 98, 252, 144}, {141, 98, 252, 131}, {141, 98, 252, 135}, {141, 98, 252, 138}},
Owned: true, Owned: true,
DefaultPort: 1196,
}, },
{ {
Country: "uk", Country: "uk",
City: "london", City: "london",
ISP: "m247", ISP: "m247",
IPs: []net.IP{{185, 200, 118, 105}, {185, 212, 168, 244}}, IPs: []net.IP{{185, 200, 118, 105}, {185, 212, 168, 244}},
DefaultPort: 1196,
}, },
{ {
Country: "uk", Country: "uk",
City: "manchester", City: "manchester",
ISP: "m247", ISP: "m247",
IPs: []net.IP{{89, 238, 130, 66}, {81, 92, 205, 10}, {89, 238, 130, 74}, {81, 92, 205, 18}, {81, 92, 205, 26}, {89, 238, 183, 244}, {89, 238, 132, 36}, {217, 151, 98, 68}, {37, 120, 159, 164}, {89, 238, 183, 60}}, IPs: []net.IP{{89, 238, 130, 66}, {81, 92, 205, 10}, {89, 238, 130, 74}, {81, 92, 205, 18}, {81, 92, 205, 26}, {89, 238, 183, 244}, {89, 238, 132, 36}, {217, 151, 98, 68}, {37, 120, 159, 164}, {89, 238, 183, 60}},
DefaultPort: 1196,
}, },
{ {
Country: "greece", Country: "greece",
City: "athens", City: "athens",
ISP: "aweb", ISP: "aweb",
IPs: []net.IP{{185, 226, 67, 168}}, IPs: []net.IP{{185, 226, 67, 168}},
DefaultPort: 1302,
}, },
{ {
Country: "hong kong", Country: "hong kong",
City: "hong kong", City: "hong kong",
ISP: "leaseweb", ISP: "leaseweb",
IPs: []net.IP{{209, 58, 185, 53}, {209, 58, 184, 146}}, IPs: []net.IP{{209, 58, 185, 53}, {209, 58, 184, 146}},
DefaultPort: 1194,
}, },
{ {
Country: "hungary", Country: "hungary",
City: "budapest", City: "budapest",
ISP: "m247", ISP: "m247",
IPs: []net.IP{{185, 94, 190, 138}, {185, 189, 114, 10}}, IPs: []net.IP{{185, 94, 190, 138}, {185, 189, 114, 10}},
DefaultPort: 1300,
}, },
{ {
Country: "ireland", Country: "ireland",
City: "dublin", City: "dublin",
ISP: "m247", ISP: "m247",
IPs: []net.IP{{217, 138, 222, 90}, {217, 138, 222, 82}}, IPs: []net.IP{{217, 138, 222, 90}, {217, 138, 222, 82}},
DefaultPort: 1197,
}, },
{ {
Country: "israel", Country: "israel",
City: "tel aviv", City: "tel aviv",
ISP: "hqserv", ISP: "hqserv",
IPs: []net.IP{{185, 191, 207, 210}}, IPs: []net.IP{{185, 191, 207, 210}},
DefaultPort: 1301,
}, },
{ {
Country: "italy", Country: "italy",
City: "milan", City: "milan",
ISP: "m247", ISP: "m247",
IPs: []net.IP{{217, 138, 197, 106}, {217, 64, 113, 180}, {217, 138, 197, 98}, {217, 138, 197, 114}, {217, 64, 113, 183}}, IPs: []net.IP{{217, 138, 197, 106}, {217, 64, 113, 180}, {217, 138, 197, 98}, {217, 138, 197, 114}, {217, 64, 113, 183}},
DefaultPort: 1300,
}, },
{ {
Country: "japan", Country: "japan",
City: "tokyo", City: "tokyo",
ISP: "m247", ISP: "m247",
IPs: []net.IP{{37, 120, 210, 138}, {193, 148, 16, 218}, {37, 120, 210, 146}, {185, 242, 4, 50}, {37, 120, 210, 122}}, IPs: []net.IP{{37, 120, 210, 138}, {193, 148, 16, 218}, {37, 120, 210, 146}, {185, 242, 4, 50}, {37, 120, 210, 122}},
DefaultPort: 1300,
}, },
{ {
Country: "luxembourg", Country: "luxembourg",
City: "luxembourg", City: "luxembourg",
ISP: "evoluso", ISP: "evoluso",
IPs: []net.IP{{92, 223, 89, 160}, {92, 223, 89, 182}}, IPs: []net.IP{{92, 223, 89, 160}, {92, 223, 89, 182}},
DefaultPort: 1301,
}, },
{ {
Country: "latvia", Country: "latvia",
City: "riga", City: "riga",
ISP: "makonix", ISP: "makonix",
IPs: []net.IP{{31, 170, 22, 2}}, IPs: []net.IP{{31, 170, 22, 2}},
DefaultPort: 1300,
}, },
{ {
Country: "moldova", Country: "moldova",
City: "chisinau", City: "chisinau",
ISP: "trabia", ISP: "trabia",
IPs: []net.IP{{178, 175, 142, 194}}, IPs: []net.IP{{178, 175, 142, 194}},
DefaultPort: 1197,
}, },
{ {
Country: "netherlands", Country: "netherlands",
City: "amsterdam", City: "amsterdam",
ISP: "31173", ISP: "31173",
IPs: []net.IP{{185, 65, 134, 139}, {185, 65, 134, 133}, {185, 65, 134, 148}, {185, 65, 134, 147}, {185, 65, 134, 141}, {185, 65, 134, 140}, {185, 65, 134, 145}, {185, 65, 134, 132}, {185, 65, 134, 146}, {185, 65, 134, 143}, {185, 65, 134, 134}, {185, 65, 134, 136}, {185, 65, 134, 135}, {185, 65, 134, 142}, {185, 65, 134, 144}}, IPs: []net.IP{{185, 65, 134, 139}, {185, 65, 134, 133}, {185, 65, 134, 148}, {185, 65, 134, 147}, {185, 65, 134, 141}, {185, 65, 134, 140}, {185, 65, 134, 145}, {185, 65, 134, 132}, {185, 65, 134, 146}, {185, 65, 134, 143}, {185, 65, 134, 134}, {185, 65, 134, 136}, {185, 65, 134, 135}, {185, 65, 134, 142}, {185, 65, 134, 144}},
Owned: true, Owned: true,
DefaultPort: 1194,
}, },
{ {
Country: "norway", Country: "norway",
City: "oslo", City: "oslo",
ISP: "blix", ISP: "blix",
IPs: []net.IP{{91, 90, 44, 13}, {91, 90, 44, 18}, {91, 90, 44, 12}, {91, 90, 44, 15}, {91, 90, 44, 16}, {91, 90, 44, 17}, {91, 90, 44, 14}, {91, 90, 44, 11}}, IPs: []net.IP{{91, 90, 44, 13}, {91, 90, 44, 18}, {91, 90, 44, 12}, {91, 90, 44, 15}, {91, 90, 44, 16}, {91, 90, 44, 17}, {91, 90, 44, 14}, {91, 90, 44, 11}},
Owned: true, Owned: true,
DefaultPort: 1302,
}, },
{ {
Country: "new zealand", Country: "new zealand",
City: "auckland", City: "auckland",
ISP: "intergrid", ISP: "intergrid",
IPs: []net.IP{{103, 231, 91, 114}}, IPs: []net.IP{{103, 231, 91, 114}},
DefaultPort: 1195,
}, },
{ {
Country: "poland", Country: "poland",
City: "warsaw", City: "warsaw",
ISP: "m247", ISP: "m247",
IPs: []net.IP{{37, 120, 211, 202}, {37, 120, 156, 162}, {185, 244, 214, 210}, {37, 120, 211, 186}, {185, 244, 214, 215}, {37, 120, 211, 194}}, IPs: []net.IP{{37, 120, 211, 202}, {37, 120, 156, 162}, {185, 244, 214, 210}, {37, 120, 211, 186}, {185, 244, 214, 215}, {37, 120, 211, 194}},
DefaultPort: 1194,
}, },
{ {
Country: "portugal", Country: "portugal",
City: "lisbon", City: "lisbon",
ISP: "dotsi", ISP: "dotsi",
IPs: []net.IP{{5, 206, 231, 214}}, IPs: []net.IP{{5, 206, 231, 214}},
DefaultPort: 1194,
}, },
{ {
Country: "romania", Country: "romania",
City: "bucharest", City: "bucharest",
ISP: "m247", ISP: "m247",
IPs: []net.IP{{89, 40, 181, 146}, {185, 181, 100, 202}, {89, 40, 181, 82}, {185, 45, 13, 10}, {89, 40, 181, 210}}, IPs: []net.IP{{89, 40, 181, 146}, {185, 181, 100, 202}, {89, 40, 181, 82}, {185, 45, 13, 10}, {89, 40, 181, 210}},
DefaultPort: 1301,
}, },
{ {
Country: "serbia", Country: "serbia",
City: "belgrade", City: "belgrade",
ISP: "m247", ISP: "m247",
IPs: []net.IP{{141, 98, 103, 50}}, IPs: []net.IP{{141, 98, 103, 50}},
DefaultPort: 1301,
}, },
{ {
Country: "serbia", Country: "serbia",
City: "nis", City: "nis",
ISP: "ninet", ISP: "ninet",
IPs: []net.IP{{176, 104, 107, 118}}, IPs: []net.IP{{176, 104, 107, 118}},
DefaultPort: 1301,
}, },
{ {
Country: "sweden", Country: "sweden",
City: "gothenburg", City: "gothenburg",
ISP: "31173", ISP: "31173",
IPs: []net.IP{{185, 213, 154, 139}, {185, 213, 154, 141}, {185, 213, 154, 140}, {185, 213, 154, 132}, {185, 213, 154, 135}, {185, 213, 154, 138}, {185, 213, 154, 133}, {185, 213, 154, 131}, {185, 213, 154, 134}, {185, 213, 154, 142}, {185, 213, 154, 137}}, IPs: []net.IP{{185, 213, 154, 139}, {185, 213, 154, 141}, {185, 213, 154, 140}, {185, 213, 154, 132}, {185, 213, 154, 135}, {185, 213, 154, 138}, {185, 213, 154, 133}, {185, 213, 154, 131}, {185, 213, 154, 134}, {185, 213, 154, 142}, {185, 213, 154, 137}},
Owned: true, Owned: true,
DefaultPort: 1302,
}, },
{ {
Country: "sweden", Country: "sweden",
City: "helsingborg", City: "helsingborg",
ISP: "31173", ISP: "31173",
IPs: []net.IP{{185, 213, 152, 133}, {185, 213, 152, 132}, {185, 213, 152, 138}, {185, 213, 152, 131}, {185, 213, 152, 137}}, IPs: []net.IP{{185, 213, 152, 133}, {185, 213, 152, 132}, {185, 213, 152, 138}, {185, 213, 152, 131}, {185, 213, 152, 137}},
Owned: true, Owned: true,
DefaultPort: 1302,
}, },
{ {
Country: "sweden", Country: "sweden",
City: "malmo", City: "malmo",
ISP: "31173", ISP: "31173",
IPs: []net.IP{{193, 138, 218, 138}, {45, 83, 220, 87}, {141, 98, 255, 94}, {141, 98, 255, 85}, {141, 98, 255, 87}, {141, 98, 255, 92}, {45, 83, 220, 84}, {141, 98, 255, 86}, {45, 83, 220, 81}, {193, 138, 218, 135}, {193, 138, 218, 131}, {193, 138, 218, 136}, {141, 98, 255, 88}, {141, 98, 255, 91}, {193, 138, 218, 133}, {45, 83, 220, 89}, {45, 83, 220, 88}, {141, 98, 255, 84}, {141, 98, 255, 89}, {193, 138, 218, 134}, {45, 83, 220, 86}, {141, 98, 255, 83}, {45, 83, 220, 85}, {141, 98, 255, 90}, {141, 98, 255, 93}, {193, 138, 218, 132}, {193, 138, 218, 137}, {45, 83, 220, 91}}, IPs: []net.IP{{193, 138, 218, 138}, {45, 83, 220, 87}, {141, 98, 255, 94}, {141, 98, 255, 85}, {141, 98, 255, 87}, {141, 98, 255, 92}, {45, 83, 220, 84}, {141, 98, 255, 86}, {45, 83, 220, 81}, {193, 138, 218, 135}, {193, 138, 218, 131}, {193, 138, 218, 136}, {141, 98, 255, 88}, {141, 98, 255, 91}, {193, 138, 218, 133}, {45, 83, 220, 89}, {45, 83, 220, 88}, {141, 98, 255, 84}, {141, 98, 255, 89}, {193, 138, 218, 134}, {45, 83, 220, 86}, {141, 98, 255, 83}, {45, 83, 220, 85}, {141, 98, 255, 90}, {141, 98, 255, 93}, {193, 138, 218, 132}, {193, 138, 218, 137}, {45, 83, 220, 91}},
Owned: true, Owned: true,
DefaultPort: 1302,
}, },
{ {
Country: "sweden", Country: "sweden",
City: "stockholm", City: "stockholm",
ISP: "31173", ISP: "31173",
IPs: []net.IP{{185, 65, 135, 150}, {185, 65, 135, 153}, {185, 65, 135, 151}, {185, 65, 135, 149}, {185, 65, 135, 141}, {185, 65, 135, 144}, {185, 65, 135, 145}, {185, 65, 135, 140}, {185, 65, 135, 134}, {185, 65, 135, 139}, {185, 65, 135, 131}, {185, 65, 135, 152}, {185, 65, 135, 146}, {185, 65, 135, 138}, {185, 65, 135, 143}, {185, 65, 135, 135}, {185, 65, 135, 154}, {185, 65, 135, 136}, {185, 65, 135, 133}, {185, 65, 135, 132}}, IPs: []net.IP{{185, 65, 135, 150}, {185, 65, 135, 153}, {185, 65, 135, 151}, {185, 65, 135, 149}, {185, 65, 135, 141}, {185, 65, 135, 144}, {185, 65, 135, 145}, {185, 65, 135, 140}, {185, 65, 135, 134}, {185, 65, 135, 139}, {185, 65, 135, 131}, {185, 65, 135, 152}, {185, 65, 135, 146}, {185, 65, 135, 138}, {185, 65, 135, 143}, {185, 65, 135, 135}, {185, 65, 135, 154}, {185, 65, 135, 136}, {185, 65, 135, 133}, {185, 65, 135, 132}},
Owned: true, Owned: true,
DefaultPort: 1302,
}, },
{ {
Country: "singapore", Country: "singapore",
City: "singapore", City: "singapore",
ISP: "m247", ISP: "m247",
IPs: []net.IP{{37, 120, 208, 218}, {37, 120, 208, 234}, {37, 120, 208, 226}, {185, 128, 24, 50}}, IPs: []net.IP{{37, 120, 208, 218}, {37, 120, 208, 234}, {37, 120, 208, 226}, {185, 128, 24, 50}},
DefaultPort: 1196,
}, },
{ {
Country: "singapore", Country: "singapore",
City: "singapore", City: "singapore",
ISP: "leaseweb", ISP: "leaseweb",
IPs: []net.IP{{103, 254, 153, 82}}, IPs: []net.IP{{103, 254, 153, 82}},
DefaultPort: 1196,
}, },
{ {
Country: "usa", Country: "usa",
City: "atlanta", City: "atlanta",
ISP: "100tb", ISP: "100tb",
IPs: []net.IP{{208, 84, 153, 142}, {107, 152, 108, 62}}, IPs: []net.IP{{208, 84, 153, 142}, {107, 152, 108, 62}},
DefaultPort: 1194,
}, },
{ {
Country: "usa", Country: "usa",
City: "atlanta", City: "atlanta",
ISP: "quadranet", ISP: "quadranet",
IPs: []net.IP{{104, 129, 24, 242}}, IPs: []net.IP{{104, 129, 24, 242}},
DefaultPort: 1194,
}, },
{ {
Country: "usa", Country: "usa",
City: "atlanta", City: "atlanta",
ISP: "micfo", ISP: "micfo",
IPs: []net.IP{{155, 254, 96, 2}, {155, 254, 96, 18}, {155, 254, 96, 34}}, // 1 missing IPs: []net.IP{{155, 254, 96, 2}, {155, 254, 96, 18}, {155, 254, 96, 34}}, // 1 missing
DefaultPort: 1194,
}, },
{ {
Country: "usa", Country: "usa",
City: "chicago", City: "chicago",
ISP: "tzulo", ISP: "tzulo",
IPs: []net.IP{{68, 235, 43, 18}, {68, 235, 43, 26}, {68, 235, 43, 42}, {68, 235, 43, 50}, {68, 235, 43, 58}, {68, 235, 43, 66}, {68, 235, 43, 74}}, // 3 missing IPs: []net.IP{{68, 235, 43, 18}, {68, 235, 43, 26}, {68, 235, 43, 42}, {68, 235, 43, 50}, {68, 235, 43, 58}, {68, 235, 43, 66}, {68, 235, 43, 74}}, // 3 missing
DefaultPort: 1194,
}, },
{ {
Country: "usa", Country: "usa",
City: "chicago", City: "chicago",
ISP: "quadranet", ISP: "quadranet",
IPs: []net.IP{}, // 1 missing IPs: []net.IP{}, // 1 missing
DefaultPort: 1194,
}, },
{ {
Country: "usa", Country: "usa",
City: "dallas", City: "dallas",
ISP: "quadranet", ISP: "quadranet",
IPs: []net.IP{{96, 44, 145, 18}}, IPs: []net.IP{{96, 44, 145, 18}},
DefaultPort: 1194,
}, },
{ {
Country: "usa", Country: "usa",
City: "dallas", City: "dallas",
ISP: "100tb", ISP: "100tb",
IPs: []net.IP{{104, 200, 142, 50}, {107, 152, 102, 106}}, IPs: []net.IP{{104, 200, 142, 50}, {107, 152, 102, 106}},
DefaultPort: 1194,
}, },
{ {
Country: "usa", Country: "usa",
City: "denver", City: "denver",
ISP: "tzulo", ISP: "tzulo",
IPs: []net.IP{{198, 54, 128, 74}}, // 1 missing IPs: []net.IP{{198, 54, 128, 74}}, // 1 missing
DefaultPort: 1194,
}, },
{ {
Country: "usa", Country: "usa",
City: "los angeles", City: "los angeles",
ISP: "m247", ISP: "m247",
IPs: []net.IP{{45, 152, 182, 66}, {45, 152, 182, 74}, {45, 83, 89, 162}, {185, 230, 126, 146}}, // 7 missing IPs: []net.IP{{45, 152, 182, 66}, {45, 152, 182, 74}, {45, 83, 89, 162}, {185, 230, 126, 146}}, // 7 missing
DefaultPort: 1194,
}, },
{ {
Country: "usa", Country: "usa",
City: "los angeles", City: "los angeles",
ISP: "tzulo", ISP: "tzulo",
IPs: []net.IP{{198, 54, 129, 74}}, // 1 missing IPs: []net.IP{{198, 54, 129, 74}}, // 1 missing
DefaultPort: 1194,
}, },
{ {
Country: "usa", Country: "usa",
City: "los angeles", City: "los angeles",
ISP: "100tb", ISP: "100tb",
IPs: []net.IP{{104, 200, 152, 66}, {107, 181, 168, 130}}, IPs: []net.IP{{104, 200, 152, 66}, {107, 181, 168, 130}},
DefaultPort: 1194,
}, },
{ {
Country: "usa", Country: "usa",
City: "los angeles", City: "los angeles",
ISP: "choopa", ISP: "choopa",
IPs: []net.IP{{104, 238, 143, 58}}, // 1 missing IPs: []net.IP{{104, 238, 143, 58}}, // 1 missing
DefaultPort: 1194,
}, },
{ {
Country: "usa", Country: "usa",
City: "miami", City: "miami",
ISP: "m247", ISP: "m247",
IPs: []net.IP{{37, 120, 215, 130}, {193, 37, 252, 138}, {193, 37, 252, 154}, {37, 120, 215, 138}}, // 1 missing IPs: []net.IP{{37, 120, 215, 130}, {193, 37, 252, 138}, {193, 37, 252, 154}, {37, 120, 215, 138}}, // 1 missing
DefaultPort: 1194,
}, },
{ {
Country: "usa", Country: "usa",
City: "miami", City: "miami",
ISP: "100tb", ISP: "100tb",
IPs: []net.IP{{172, 98, 76, 114}}, IPs: []net.IP{{172, 98, 76, 114}},
DefaultPort: 1194,
}, },
{ {
Country: "usa", Country: "usa",
City: "miami", City: "miami",
ISP: "micfo", ISP: "micfo",
IPs: []net.IP{}, // 1 missing IPs: []net.IP{}, // 1 missing
DefaultPort: 1194,
}, },
{ {
Country: "usa", Country: "usa",
City: "new york", City: "new york",
ISP: "m247", ISP: "m247",
IPs: []net.IP{{185, 232, 22, 66}, {185, 232, 22, 98}, {193, 148, 18, 250}, {185, 232, 22, 10}, {217, 138, 206, 10}, {193, 148, 18, 218}, {193, 148, 18, 226}, {193, 148, 18, 194}, {87, 101, 95, 98}, {87, 101, 95, 114}, {87, 101, 95, 122}, {212, 103, 48, 226}, {176, 113, 72, 226}, {217, 138, 198, 250}, {217, 138, 206, 58}}, // 5 missing IPs: []net.IP{{185, 232, 22, 66}, {185, 232, 22, 98}, {193, 148, 18, 250}, {185, 232, 22, 10}, {217, 138, 206, 10}, {193, 148, 18, 218}, {193, 148, 18, 226}, {193, 148, 18, 194}, {87, 101, 95, 98}, {87, 101, 95, 114}, {87, 101, 95, 122}, {212, 103, 48, 226}, {176, 113, 72, 226}, {217, 138, 198, 250}, {217, 138, 206, 58}}, // 5 missing
DefaultPort: 1194,
}, },
{ {
Country: "usa", Country: "usa",
City: "new york", City: "new york",
ISP: "100tb", ISP: "100tb",
IPs: []net.IP{{107, 182, 226, 206}, {107, 182, 226, 218}}, IPs: []net.IP{{107, 182, 226, 206}, {107, 182, 226, 218}},
DefaultPort: 1194,
}, },
{ {
Country: "usa", Country: "usa",
City: "phoenix", City: "phoenix",
ISP: "100tb", ISP: "100tb",
IPs: []net.IP{}, // 1 missing IPs: []net.IP{}, // 1 missing
DefaultPort: 1194,
}, },
{ {
Country: "usa", Country: "usa",
City: "phoenix", City: "phoenix",
ISP: "micfo", ISP: "micfo",
IPs: []net.IP{{192, 200, 24, 82}}, // 1 missing IPs: []net.IP{{192, 200, 24, 82}}, // 1 missing
DefaultPort: 1194,
}, },
{ {
Country: "usa", Country: "usa",
City: "piscataway", City: "piscataway",
ISP: "choopa", ISP: "choopa",
IPs: []net.IP{{108, 61, 78, 138}, {108, 61, 48, 115}, {66, 55, 147, 59}}, IPs: []net.IP{{108, 61, 78, 138}, {108, 61, 48, 115}, {66, 55, 147, 59}},
DefaultPort: 1194,
}, },
{ {
Country: "usa", Country: "usa",
City: "seattle", City: "seattle",
ISP: "100tb", ISP: "100tb",
IPs: []net.IP{{104, 200, 129, 202}, {104, 200, 129, 150}, {104, 200, 129, 110}}, // 1 missing IPs: []net.IP{{104, 200, 129, 202}, {104, 200, 129, 150}, {104, 200, 129, 110}}, // 1 missing
DefaultPort: 1194,
}, },
{ {
Country: "usa", Country: "usa",
City: "seattle", City: "seattle",
ISP: "micfo", ISP: "micfo",
IPs: []net.IP{{104, 128, 136, 146}}, IPs: []net.IP{{104, 128, 136, 146}},
DefaultPort: 1194,
}, },
{ {
Country: "usa", Country: "usa",
City: "san francisco", City: "san francisco",
ISP: "micfo", ISP: "micfo",
IPs: []net.IP{{209, 209, 238, 34}}, // 1 missing IPs: []net.IP{{209, 209, 238, 34}}, // 1 missing
DefaultPort: 1194,
}, },
{ {
Country: "usa", Country: "usa",
City: "salt lake city", City: "salt lake city",
ISP: "100tb", ISP: "100tb",
IPs: []net.IP{{107, 182, 238, 229}, {107, 182, 235, 233}, {67, 212, 238, 236}, {67, 212, 238, 237}, {67, 212, 238, 239}, {107, 182, 239, 185}, {107, 182, 239, 170}}, // 2 missing IPs: []net.IP{{107, 182, 238, 229}, {107, 182, 235, 233}, {67, 212, 238, 236}, {67, 212, 238, 237}, {67, 212, 238, 239}, {107, 182, 239, 185}, {107, 182, 239, 170}}, // 2 missing
DefaultPort: 1194,
}, },
{ {
Country: "usa", Country: "usa",
City: "secaucus", City: "secaucus",
ISP: "quadranet", ISP: "quadranet",
IPs: []net.IP{{23, 226, 131, 154}}, // 1 missing IPs: []net.IP{{23, 226, 131, 154}}, // 1 missing
DefaultPort: 1194,
}, },
} }
} }

View File

@@ -8,12 +8,11 @@ type PIAServer struct {
} }
type MullvadServer struct { type MullvadServer struct {
IPs []net.IP IPs []net.IP
Country string Country string
City string City string
ISP string ISP string
Owned bool Owned bool
DefaultPort uint16
} }
type WindscribeServer struct { type WindscribeServer struct {

View File

@@ -27,7 +27,7 @@ func (r *reader) GetPortForwarding() (activated bool, err error) {
// GetPortForwardingStatusFilepath obtains the port forwarding status file path // GetPortForwardingStatusFilepath obtains the port forwarding status file path
// from the environment variable PORT_FORWARDING_STATUS_FILE // from the environment variable PORT_FORWARDING_STATUS_FILE
func (r *reader) GetPortForwardingStatusFilepath() (filepath models.Filepath, err error) { func (r *reader) GetPortForwardingStatusFilepath() (filepath models.Filepath, err error) {
filepathStr, err := r.envParams.GetPath("PORT_FORWARDING_STATUS_FILE", libparams.Default("/forwarded_port"), libparams.CaseSensitiveValue()) filepathStr, err := r.envParams.GetPath("PORT_FORWARDING_STATUS_FILE", libparams.Default("/tmp/gluetun/forwarded_port"), libparams.CaseSensitiveValue())
return models.Filepath(filepathStr), err return models.Filepath(filepathStr), err
} }

View File

@@ -23,6 +23,6 @@ func (r *reader) GetTimezone() (timezone string, err error) {
// GetIPStatusFilepath obtains the IP status file path // GetIPStatusFilepath obtains the IP status file path
// from the environment variable IP_STATUS_FILE // from the environment variable IP_STATUS_FILE
func (r *reader) GetIPStatusFilepath() (filepath models.Filepath, err error) { func (r *reader) GetIPStatusFilepath() (filepath models.Filepath, err error) {
filepathStr, err := r.envParams.GetPath("IP_STATUS_FILE", libparams.Default("/ip"), libparams.CaseSensitiveValue()) filepathStr, err := r.envParams.GetPath("IP_STATUS_FILE", libparams.Default("/tmp/gluetun/ip"), libparams.CaseSensitiveValue())
return models.Filepath(filepathStr), err return models.Filepath(filepathStr), err
} }

View File

@@ -42,8 +42,13 @@ func (m *mullvad) GetOpenVPNConnections(selection models.ServerSelection) (conne
return nil, fmt.Errorf("no server found for country %q, city %q and ISP %q", selection.Country, selection.City, selection.ISP) return nil, fmt.Errorf("no server found for country %q, city %q and ISP %q", selection.Country, selection.City, selection.ISP)
} }
var defaultPort uint16 = 1194
if selection.Protocol == constants.TCP {
defaultPort = 443
}
for _, server := range servers { for _, server := range servers {
port := server.DefaultPort port := defaultPort
if selection.CustomPort > 0 { if selection.CustomPort > 0 {
port = selection.CustomPort port = selection.CustomPort
} }

View File

@@ -1,6 +1,8 @@
package settings package settings
import ( import (
"fmt"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants"
"github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/params" "github.com/qdm12/gluetun/internal/params"
@@ -67,6 +69,19 @@ func GetMullvadSettings(paramsReader params.Reader) (settings models.ProviderSet
if err != nil { if err != nil {
return settings, err return settings, err
} }
if settings.ServerSelection.Protocol == constants.TCP {
switch settings.ServerSelection.CustomPort {
case 0, 80, 443, 1401:
default:
return settings, fmt.Errorf("port %d is not valid for TCP protocol", settings.ServerSelection.CustomPort)
}
} else {
switch settings.ServerSelection.CustomPort {
case 0, 53, 1194, 1195, 1196, 1197, 1300, 1301, 1302, 1303, 1400:
default:
return settings, fmt.Errorf("port %d is not valid for UDP protocol", settings.ServerSelection.CustomPort)
}
}
return settings, nil return settings, nil
} }

View File

@@ -1,41 +0,0 @@
package shadowsocks
import (
"context"
"fmt"
"io"
"strings"
"github.com/qdm12/gluetun/internal/constants"
)
func (c *configurator) Start(ctx context.Context, server string, port uint16, password string, log bool) (stdout, stderr io.ReadCloser, waitFn func() error, err error) {
c.logger.Info("starting shadowsocks server")
args := []string{
"-c", string(constants.ShadowsocksConf),
"-p", fmt.Sprintf("%d", port),
"-k", password,
}
if log {
args = append(args, "-v")
}
stdout, stderr, waitFn, err = c.commander.Start(ctx, "ss-server", args...)
return stdout, stderr, waitFn, err
}
// Version obtains the version of the installed shadowsocks server
func (c *configurator) Version(ctx context.Context) (string, error) {
output, err := c.commander.Run(ctx, "ss-server", "-h")
if err != nil {
return "", err
}
lines := strings.Split(output, "\n")
if len(lines) < 2 {
return "", fmt.Errorf("ss-server -h: not enough lines in %q", output)
}
words := strings.Fields(lines[1])
if len(words) < 2 {
return "", fmt.Errorf("ss-server -h: line 2 is too short: %q", lines[1])
}
return words[1], nil
}

View File

@@ -1,51 +0,0 @@
package shadowsocks
import (
"encoding/json"
"fmt"
"github.com/qdm12/gluetun/internal/constants"
"github.com/qdm12/golibs/files"
)
func (c *configurator) MakeConf(port uint16, password, method, nameserver string, uid, gid int) (err error) {
c.logger.Info("generating configuration file")
data := generateConf(port, password, method, nameserver)
return c.fileManager.WriteToFile(
string(constants.ShadowsocksConf),
data,
files.Ownership(uid, gid),
files.Permissions(0400))
}
func generateConf(port uint16, password, method, nameserver string) (data []byte) {
conf := struct {
Server string `json:"server"`
User string `json:"user"`
Method string `json:"method"`
Timeout uint `json:"timeout"`
FastOpen bool `json:"fast_open"`
Mode string `json:"mode"`
PortPassword map[string]string `json:"port_password"`
Workers uint `json:"workers"`
Interface string `json:"interface"`
Nameserver *string `json:"nameserver,omitempty"`
}{
Server: "0.0.0.0",
User: "nonrootuser",
Method: method,
Timeout: 30,
FastOpen: false,
Mode: "tcp_and_udp",
PortPassword: map[string]string{
fmt.Sprintf("%d", port): password,
},
Workers: 2,
Interface: "tun",
}
if len(nameserver) > 0 {
conf.Nameserver = &nameserver
}
data, _ = json.Marshal(conf)
return data
}

View File

@@ -1,81 +0,0 @@
package shadowsocks
import (
"fmt"
"testing"
"github.com/golang/mock/gomock"
"github.com/qdm12/gluetun/internal/constants"
"github.com/qdm12/golibs/files"
"github.com/qdm12/golibs/files/mock_files"
"github.com/qdm12/golibs/logging/mock_logging"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func Test_generateConf(t *testing.T) {
t.Parallel()
tests := map[string]struct {
port uint16
password string
nameserver string
data []byte
}{
"no data": {
data: []byte(`{"server":"0.0.0.0","user":"nonrootuser","method":"chacha20-ietf-poly1305","timeout":30,"fast_open":false,"mode":"tcp_and_udp","port_password":{"0":""},"workers":2,"interface":"tun"}`),
},
"data": {
port: 2000,
password: "abcde",
nameserver: "127.0.0.1",
data: []byte(`{"server":"0.0.0.0","user":"nonrootuser","method":"chacha20-ietf-poly1305","timeout":30,"fast_open":false,"mode":"tcp_and_udp","port_password":{"2000":"abcde"},"workers":2,"interface":"tun","nameserver":"127.0.0.1"}`),
},
}
for name, tc := range tests {
tc := tc
t.Run(name, func(t *testing.T) {
t.Parallel()
data := generateConf(tc.port, tc.password, "chacha20-ietf-poly1305", tc.nameserver)
assert.Equal(t, tc.data, data)
})
}
}
func Test_MakeConf(t *testing.T) {
t.Parallel()
tests := map[string]struct {
writeErr error
err error
}{
"no write error": {},
"write error": {
writeErr: fmt.Errorf("error"),
err: fmt.Errorf("error"),
},
}
for name, tc := range tests {
tc := tc
t.Run(name, func(t *testing.T) {
t.Parallel()
mockCtrl := gomock.NewController(t)
defer mockCtrl.Finish()
logger := mock_logging.NewMockLogger(mockCtrl)
logger.EXPECT().Info("generating configuration file").Times(1)
fileManager := mock_files.NewMockFileManager(mockCtrl)
fileManager.EXPECT().WriteToFile(
string(constants.ShadowsocksConf),
[]byte(`{"server":"0.0.0.0","user":"nonrootuser","method":"chacha20-ietf-poly1305","timeout":30,"fast_open":false,"mode":"tcp_and_udp","port_password":{"2000":"abcde"},"workers":2,"interface":"tun","nameserver":"127.0.0.1"}`),
gomock.AssignableToTypeOf(files.Ownership(0, 0)),
gomock.AssignableToTypeOf(files.Ownership(0, 0)),
).Return(tc.writeErr).Times(1)
c := &configurator{logger: logger, fileManager: fileManager}
err := c.MakeConf(2000, "abcde", "chacha20-ietf-poly1305", "127.0.0.1", 1000, 1001)
if tc.err != nil {
require.Error(t, err)
assert.Equal(t, tc.err.Error(), err.Error())
} else {
assert.NoError(t, err)
}
})
}
}

View File

@@ -0,0 +1,32 @@
package shadowsocks
import "github.com/qdm12/golibs/logging"
type logAdapter struct {
logger logging.Logger
enabled bool
}
func (l *logAdapter) Info(s string) {
if l.enabled {
l.logger.Info(s)
}
}
func (l *logAdapter) Debug(s string) {
if l.enabled {
l.logger.Debug(s)
}
}
func (l *logAdapter) Error(s string) {
if l.enabled {
l.logger.Error(s)
}
}
func adaptLogger(logger logging.Logger, enabled bool) *logAdapter {
return &logAdapter{
logger: logger,
enabled: enabled,
}
}

View File

@@ -2,13 +2,14 @@ package shadowsocks
import ( import (
"context" "context"
"fmt"
"sync" "sync"
"time" "time"
"github.com/qdm12/gluetun/internal/firewall" "github.com/qdm12/gluetun/internal/firewall"
"github.com/qdm12/gluetun/internal/settings" "github.com/qdm12/gluetun/internal/settings"
"github.com/qdm12/golibs/command"
"github.com/qdm12/golibs/logging" "github.com/qdm12/golibs/logging"
shadowsockslib "github.com/qdm12/ss-server/pkg"
) )
type Looper interface { type Looper interface {
@@ -21,15 +22,10 @@ type Looper interface {
} }
type looper struct { type looper struct {
conf Configurator
firewallConf firewall.Configurator firewallConf firewall.Configurator
settings settings.ShadowSocks settings settings.ShadowSocks
settingsMutex sync.RWMutex settingsMutex sync.RWMutex
dnsSettings settings.DNS // TODO
logger logging.Logger logger logging.Logger
streamMerger command.StreamMerger
uid int
gid int
defaultInterface string defaultInterface string
restart chan struct{} restart chan struct{}
start chan struct{} start chan struct{}
@@ -44,17 +40,12 @@ func (l *looper) logAndWait(ctx context.Context, err error) {
<-ctx.Done() <-ctx.Done()
} }
func NewLooper(conf Configurator, firewallConf firewall.Configurator, settings settings.ShadowSocks, dnsSettings settings.DNS, func NewLooper(firewallConf firewall.Configurator, settings settings.ShadowSocks,
logger logging.Logger, streamMerger command.StreamMerger, uid, gid int, defaultInterface string) Looper { logger logging.Logger, defaultInterface string) Looper {
return &looper{ return &looper{
conf: conf,
firewallConf: firewallConf, firewallConf: firewallConf,
settings: settings, settings: settings,
dnsSettings: dnsSettings,
logger: logger.WithPrefix("shadowsocks: "), logger: logger.WithPrefix("shadowsocks: "),
streamMerger: streamMerger,
uid: uid,
gid: gid,
defaultInterface: defaultInterface, defaultInterface: defaultInterface,
restart: make(chan struct{}), restart: make(chan struct{}),
start: make(chan struct{}), start: make(chan struct{}),
@@ -126,12 +117,8 @@ func (l *looper) Run(ctx context.Context, wg *sync.WaitGroup) {
} }
} }
nameserver := l.dnsSettings.PlaintextAddress.String()
if l.dnsSettings.Enabled {
nameserver = "127.0.0.1"
}
settings := l.GetSettings() settings := l.GetSettings()
err := l.conf.MakeConf(settings.Port, settings.Password, settings.Method, nameserver, l.uid, l.gid) server, err := shadowsockslib.NewServer(settings.Method, settings.Password, adaptLogger(l.logger, settings.Log))
if err != nil { if err != nil {
l.logAndWait(ctx, err) l.logAndWait(ctx, err)
continue continue
@@ -150,19 +137,16 @@ func (l *looper) Run(ctx context.Context, wg *sync.WaitGroup) {
previousPort = settings.Port previousPort = settings.Port
shadowsocksCtx, shadowsocksCancel := context.WithCancel(context.Background()) shadowsocksCtx, shadowsocksCancel := context.WithCancel(context.Background())
stdout, stderr, waitFn, err := l.conf.Start(shadowsocksCtx, "0.0.0.0", settings.Port, settings.Password, settings.Log)
waitError := make(chan error)
go func() {
waitError <- server.Listen(shadowsocksCtx, fmt.Sprintf("0.0.0.0:%d", settings.Port))
}()
if err != nil { if err != nil {
shadowsocksCancel() shadowsocksCancel()
l.logAndWait(ctx, err) l.logAndWait(ctx, err)
continue continue
} }
go l.streamMerger.Merge(shadowsocksCtx, stdout, command.MergeName("shadowsocks"))
go l.streamMerger.Merge(shadowsocksCtx, stderr, command.MergeName("shadowsocks error"))
waitError := make(chan error)
go func() {
err := waitFn() // blocking
waitError <- err
}()
stayHere := true stayHere := true
for stayHere { for stayHere {

View File

@@ -1,29 +0,0 @@
package shadowsocks
import (
"context"
"io"
"github.com/qdm12/golibs/command"
"github.com/qdm12/golibs/files"
"github.com/qdm12/golibs/logging"
)
type Configurator interface {
Version(ctx context.Context) (string, error)
MakeConf(port uint16, password, method, nameserver string, uid, gid int) (err error)
Start(ctx context.Context, server string, port uint16, password string, log bool) (stdout, stderr io.ReadCloser, waitFn func() error, err error)
}
type configurator struct {
fileManager files.FileManager
logger logging.Logger
commander command.Commander
}
func NewConfigurator(fileManager files.FileManager, logger logging.Logger) Configurator {
return &configurator{
fileManager: fileManager,
logger: logger.WithPrefix("shadowsocks configurator: "),
commander: command.NewCommander()}
}