mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 14:44:02 +03:00
Fix lint errors
This commit is contained in:
+23
-10
@@ -10,26 +10,28 @@ import (
|
||||
"github.com/juju/errors"
|
||||
)
|
||||
|
||||
// Config represents common configuration of mtg.
|
||||
type Config struct {
|
||||
Debug bool
|
||||
Verbose bool
|
||||
BindIP net.IP
|
||||
BindPort uint16
|
||||
Debug bool
|
||||
Verbose bool
|
||||
|
||||
PublicIPv4 net.IP
|
||||
BindPort uint16
|
||||
PublicIPv4Port uint16
|
||||
PublicIPv6 net.IP
|
||||
PublicIPv6Port uint16
|
||||
|
||||
StatsIP net.IP
|
||||
StatsPort uint16
|
||||
StatsPort uint16
|
||||
|
||||
TimeoutRead time.Duration
|
||||
TimeoutWrite time.Duration
|
||||
|
||||
BindIP net.IP
|
||||
PublicIPv4 net.IP
|
||||
PublicIPv6 net.IP
|
||||
StatsIP net.IP
|
||||
|
||||
Secret []byte
|
||||
}
|
||||
|
||||
// URLs contains links to the proxy (tg://, t.me) and their QR codes.
|
||||
type URLs struct {
|
||||
TG string `json:"tg_url"`
|
||||
TMe string `json:"tme_url"`
|
||||
@@ -37,27 +39,33 @@ type URLs struct {
|
||||
TMeQRCode string `json:"tme_qrcode"`
|
||||
}
|
||||
|
||||
// IPURLs contains links to both ipv4 and ipv6 of the proxy.
|
||||
type IPURLs struct {
|
||||
IPv4 URLs `json:"ipv4"`
|
||||
IPv6 URLs `json:"ipv6"`
|
||||
}
|
||||
|
||||
// BindAddr returns connection for this server to bind to.
|
||||
func (c *Config) BindAddr() string {
|
||||
return getAddr(c.BindIP, c.BindPort)
|
||||
}
|
||||
|
||||
// IPv4Addr returns connection string to ipv6 for mtproto proxy.
|
||||
func (c *Config) IPv4Addr() string {
|
||||
return getAddr(c.PublicIPv4, c.PublicIPv4Port)
|
||||
}
|
||||
|
||||
// IPv6Addr returns connection string to ipv6 for mtproto proxy.
|
||||
func (c *Config) IPv6Addr() string {
|
||||
return getAddr(c.PublicIPv6, c.PublicIPv6Port)
|
||||
}
|
||||
|
||||
// StatAddr returns connection string to the stats API.
|
||||
func (c *Config) StatAddr() string {
|
||||
return getAddr(c.StatsIP, c.StatsPort)
|
||||
}
|
||||
|
||||
// GetURLs returns configured IPURLs instance with links to this server.
|
||||
func (c *Config) GetURLs() IPURLs {
|
||||
return IPURLs{
|
||||
IPv4: getURLs(c.PublicIPv4, c.PublicIPv4Port, c.Secret),
|
||||
@@ -69,7 +77,10 @@ func getAddr(host fmt.Stringer, port uint16) string {
|
||||
return net.JoinHostPort(host.String(), strconv.Itoa(int(port)))
|
||||
}
|
||||
|
||||
func NewConfig(debug, verbose bool,
|
||||
// NewConfig returns new configuration. If required, it manages and
|
||||
// fetches data from external sources. Parameters passed to this
|
||||
// function, should come from command line arguments.
|
||||
func NewConfig(debug, verbose bool, // nolint: gocyclo
|
||||
bindIP net.IP, bindPort uint16,
|
||||
publicIPv4 net.IP, PublicIPv4Port uint16,
|
||||
publicIPv6 net.IP, publicIPv6Port uint16,
|
||||
@@ -120,6 +131,8 @@ func NewConfig(debug, verbose bool,
|
||||
PublicIPv4Port: PublicIPv4Port,
|
||||
PublicIPv6: publicIPv6,
|
||||
PublicIPv6Port: publicIPv6Port,
|
||||
StatsIP: statsIP,
|
||||
StatsPort: statsPort,
|
||||
TimeoutRead: timeoutRead,
|
||||
TimeoutWrite: timeoutWrite,
|
||||
Secret: secretBytes,
|
||||
|
||||
@@ -22,7 +22,7 @@ func fetchIP(url string) (net.IP, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
defer resp.Body.Close() // nolint: errcheck
|
||||
|
||||
respData, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ func getURLs(addr net.IP, port uint16, secret []byte) (urls URLs) {
|
||||
values.Set("secret", hex.EncodeToString(secret))
|
||||
|
||||
urls.TG = makeTGURL(values)
|
||||
urls.TMe = makeTGURL(values)
|
||||
urls.TMe = makeTMeURL(values)
|
||||
urls.TGQRCode = makeQRCodeURL(urls.TG)
|
||||
urls.TMeQRCode = makeQRCodeURL(urls.TG)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user