Propagate adtag

This commit is contained in:
9seconds
2018-07-04 18:08:04 +03:00
parent 69c4997fd4
commit c35c482de7
3 changed files with 17 additions and 3 deletions
+11 -1
View File
@@ -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