mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 17:14:02 +03:00
Propagate adtag
This commit is contained in:
+11
-1
@@ -38,6 +38,7 @@ type Config struct {
|
||||
StatsIP net.IP
|
||||
|
||||
Secret []byte
|
||||
AdTag []byte
|
||||
}
|
||||
|
||||
// URLs contains links to the proxy (tg://, t.me) and their QR codes.
|
||||
@@ -89,7 +90,7 @@ func NewConfig(debug, verbose bool, // nolint: gocyclo
|
||||
publicIPv4 net.IP, PublicIPv4Port uint16,
|
||||
publicIPv6 net.IP, publicIPv6Port uint16,
|
||||
statsIP net.IP, statsPort uint16,
|
||||
secret string) (*Config, error) {
|
||||
secret, adtag string) (*Config, error) {
|
||||
if len(secret) != 32 {
|
||||
return nil, errors.New("Telegram demands secret of length 32")
|
||||
}
|
||||
@@ -98,6 +99,14 @@ func NewConfig(debug, verbose bool, // nolint: gocyclo
|
||||
return nil, errors.Annotate(err, "Cannot create config")
|
||||
}
|
||||
|
||||
var adTagBytes []byte
|
||||
if len(adtag) != 0 {
|
||||
adTagBytes, err = hex.DecodeString(adtag)
|
||||
if err != nil {
|
||||
return nil, errors.Annotate(err, "Cannot create config")
|
||||
}
|
||||
}
|
||||
|
||||
if publicIPv4 == nil {
|
||||
publicIPv4, err = getGlobalIPv4()
|
||||
if err != nil {
|
||||
@@ -138,6 +147,7 @@ func NewConfig(debug, verbose bool, // nolint: gocyclo
|
||||
StatsIP: statsIP,
|
||||
StatsPort: statsPort,
|
||||
Secret: secretBytes,
|
||||
AdTag: adTagBytes,
|
||||
}
|
||||
|
||||
return conf, nil
|
||||
|
||||
Reference in New Issue
Block a user