From e0833e86d91d40a39b20818515a7edc13fdae9f7 Mon Sep 17 00:00:00 2001 From: 9seconds Date: Wed, 10 Mar 2021 11:12:10 +0300 Subject: [PATCH] Update configuration file with proxies specification --- example.config.toml | 35 +++++++++++++++++++++++++++++++++++ raw_config.go | 17 +++++++++-------- 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/example.config.toml b/example.config.toml index da7c108..3397220 100644 --- a/example.config.toml +++ b/example.config.toml @@ -60,6 +60,41 @@ cloak-port = 443 # By default we use Quad9. doh-hostname = "9.9.9.9" +# mtg can work via proxies (for now, we support only socks5). Proxy +# configuration is done via list. So, you can specify many proxies +# there. +# +# Actually, if you supply an empty list, then no proxies are going to be +# used. If you supply a single proxy, then mtg will use it exclusively. +# If you supply >= 2, then mtg will load balance between them. +# +# If you add an empty string here, this is an equivalent of 'plain network', +# with no proxy usage. +# +# Proxy configuration is done via ordinary URI schema: +# +# socks5://user:password@host:port?open_threshold=5&half_open_timeout=1m&reset_failures_timeout=10s +# + +# Only socks5 proxy is used. user/password is optional. As you can +# see, you can specify some parameters in GET query. These parameters +# configure circuit breaker. +# +# open_threshold means a number of errors which should happen so we stop +# use a proxy. +# +# half_open_timeout means a time period (in Golang duration notation) +# after which we can retry with this proxy +# +# reset_failures_timeout means a time period when we flush out errors +# when circuit breaker in closed state. +# +# Please see https://docs.microsoft.com/en-us/azure/architecture/patterns/circuit-breaker +# on details about circuit breakers. +proxies = [ + # "socks5://user:password@host:port?open_threshold=5&half_open_timeout=1m&reset_failures_timeout=10s" +] + # public ip addresses of the server. Actually, it is required only to # generate a correct access file. if you use default values here, mtg # will try to resolve these IPs on its own. diff --git a/raw_config.go b/raw_config.go index 7de66d9..7e1b3d8 100644 --- a/raw_config.go +++ b/raw_config.go @@ -8,13 +8,13 @@ import ( ) type rawConfig struct { - Debug bool `toml:"debug"` - Secret string `toml:"secret"` - BindTo string `toml:"bind-to"` - TCPBuffer string `toml:"tcp-buffer"` - PreferIP string `toml:"prefer-ip"` - CloakPort uint `toml:"cloak-port"` - Probes struct { + Debug bool `toml:"debug"` + Secret string `toml:"secret"` + BindTo string `toml:"bind-to"` + TCPBuffer string `toml:"tcp-buffer"` + PreferIP string `toml:"prefer-ip"` + CloakPort uint `toml:"cloak-port"` + Probes struct { Time struct { Enabled bool `toml:"enabled"` AllowSkewness string `toml:"allow-skewness"` @@ -34,7 +34,8 @@ type rawConfig struct { Telegram string `toml:"telegram"` Default string `toml:"default"` } `toml:"dialers"` - DOHHostname string `toml:"doh-hostname"` + DOHHostname string `toml:"doh-hostname"` + Proxies []string `toml:"proxies"` } `toml:"network"` Stats struct { StatsD struct {