Switch to golangci-lint

This commit is contained in:
9seconds
2018-07-18 08:37:37 +03:00
parent c1e5c33076
commit c1b862c1e9
19 changed files with 194 additions and 112 deletions
+67 -50
View File
@@ -25,74 +25,90 @@ import (
var (
app = kingpin.New("mtg", "Simple MTPROTO proxy.")
debug = app.Flag("debug", "Run in debug mode.").
debug = app.Flag("debug",
"Run in debug mode.").
Short('d').
Envar("MTG_DEBUG").
Bool()
verbose = app.Flag("verbose", "Run in verbose mode.").
verbose = app.Flag("verbose",
"Run in verbose mode.").
Short('v').
Envar("MTG_VERBOSE").
Bool()
bindIP = app.Flag("bind-ip", "Which IP to bind to.").
bindIP = app.Flag("bind-ip",
"Which IP to bind to.").
Short('b').
Envar("MTG_IP").
Default("127.0.0.1").
IP()
bindPort = app.Flag("bind-port", "Which port to bind to.").
Short('p').
Envar("MTG_PORT").
Default("3128").
Uint16()
bindPort = app.Flag("bind-port",
"Which port to bind to.").
Short('p').
Envar("MTG_PORT").
Default("3128").
Uint16()
publicIPv4 = app.Flag("public-ipv4", "Which IPv4 address is public.").
Short('4').
Envar("MTG_IPV4").
IP()
publicIPv4Port = app.Flag("public-ipv4-port", "Which IPv4 port is public. Default is 'bind-port' value.").
Envar("MTG_IPV4_PORT").
Uint16()
publicIPv4 = app.Flag("public-ipv4",
"Which IPv4 address is public.").
Short('4').
Envar("MTG_IPV4").
IP()
publicIPv4Port = app.Flag("public-ipv4-port",
"Which IPv4 port is public. Default is 'bind-port' value.").
Envar("MTG_IPV4_PORT").
Uint16()
publicIPv6 = app.Flag("public-ipv6", "Which IPv6 address is public.").
Short('6').
Envar("MTG_IPV6").
IP()
publicIPv6Port = app.Flag("public-ipv6-port", "Which IPv6 port is public. Default is 'bind-port' value.").
Envar("MTG_IPV6_PORT").
Uint16()
publicIPv6 = app.Flag("public-ipv6",
"Which IPv6 address is public.").
Short('6').
Envar("MTG_IPV6").
IP()
publicIPv6Port = app.Flag("public-ipv6-port",
"Which IPv6 port is public. Default is 'bind-port' value.").
Envar("MTG_IPV6_PORT").
Uint16()
statsIP = app.Flag("stats-ip", "Which IP bind stats server to.").
statsIP = app.Flag("stats-ip",
"Which IP bind stats server to.").
Short('t').
Envar("MTG_STATS_IP").
Default("127.0.0.1").
IP()
statsPort = app.Flag("stats-port", "Which port bind stats to.").
Short('q').
Envar("MTG_STATS_PORT").
Default("3129").
Uint16()
statsPort = app.Flag("stats-port",
"Which port bind stats to.").
Short('q').
Envar("MTG_STATS_PORT").
Default("3129").
Uint16()
statsdIP = app.Flag("statsd-ip", "Which IP should we use for working with statsd.").
Envar("MTG_STATSD_IP").
String()
statsdPort = app.Flag("statsd-port", "Which port should we use for working with statsd.").
Envar("MTG_STATSD_PORT").
Default("8125").
Uint16()
statsdNetwork = app.Flag("statsd-network", "Which network is used to work with statsd. Only 'tcp' and 'udp' are supported.").
Envar("MTG_STATSD_NETWORK").
Default("udp").
String()
statsdPrefix = app.Flag("statsd-prefix", "Which bucket prefix should we use for sending stats to statsd.").
Envar("MTG_STATSD_PREFIX").
Default("mtg").
String()
statsdTagsFormat = app.Flag("statsd-tags-format", "Which tag format should we use to send stats metrics. Valid options are 'datadog' and 'influxdb'.").
Envar("MTG_STATSD_TAGS_FORMAT").
String()
statsdTags = app.Flag("statsd-tags", "Tags to use for working with statsd (specified as 'key=value').").
Envar("MTG_STATSD_TAGS").
StringMap()
statsdIP = app.Flag("statsd-ip",
"Which IP should we use for working with statsd.").
Envar("MTG_STATSD_IP").
String()
statsdPort = app.Flag("statsd-port",
"Which port should we use for working with statsd.").
Envar("MTG_STATSD_PORT").
Default("8125").
Uint16()
statsdNetwork = app.Flag("statsd-network",
"Which network is used to work with statsd. Only 'tcp' and 'udp' are supported.").
Envar("MTG_STATSD_NETWORK").
Default("udp").
String()
statsdPrefix = app.Flag("statsd-prefix",
"Which bucket prefix should we use for sending stats to statsd.").
Envar("MTG_STATSD_PREFIX").
Default("mtg").
String()
statsdTagsFormat = app.Flag("statsd-tags-format",
"Which tag format should we use to send stats metrics. Valid options are 'datadog' and 'influxdb'.").
Envar("MTG_STATSD_TAGS_FORMAT").
String()
statsdTags = app.Flag("statsd-tags",
"Tags to use for working with statsd (specified as 'key=value').").
Envar("MTG_STATSD_TAGS").
StringMap()
secret = app.Arg("secret", "Secret of this proxy.").Required().String()
adtag = app.Arg("adtag", "ADTag of the proxy.").String()
@@ -150,7 +166,8 @@ func main() {
zap.S().Warnw("Could not fetch time data from NTP")
} else {
if diff >= time.Second {
usage(fmt.Sprintf("You choose to use middle proxy but your clock drift (%s) is bigger than 1 second. Please, sync your time", diff))
usage(fmt.Sprintf("You choose to use middle proxy but your clock drift (%s) "+
"is bigger than 1 second. Please, sync your time", diff))
}
go ntp.AutoUpdate()
}