Skip to content

Commit

Permalink
Respect OTP length key from configuration, set default to 12
Browse files Browse the repository at this point in the history
  • Loading branch information
mudler committed Oct 30, 2021
1 parent 1e670fe commit 139c93d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion pkg/discovery/dht.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (d *DHT) Option(ctx context.Context) func(c *libp2p.Config) error {
}
func (d *DHT) Rendezvous() string {
if d.OTPKey != "" {
totp := gotp.NewTOTP(d.OTPKey, 6, d.OTPInterval, nil)
totp := gotp.NewTOTP(d.OTPKey, d.KeyLength, d.OTPInterval, nil)

//totp := gotp.NewDefaultTOTP(d.OTPKey)
rv := totp.Now()
Expand All @@ -65,6 +65,10 @@ func (d *DHT) startDHT(ctx context.Context, h host.Host) (*dht.IpfsDHT, error) {
}

func (d *DHT) Run(c *zap.Logger, ctx context.Context, host host.Host) error {
if d.KeyLength == 0 {
d.KeyLength = 12
}

d.console = c
if len(d.BootstrapPeers) == 0 {
d.BootstrapPeers = dht.DefaultBootstrapPeers
Expand Down
2 changes: 1 addition & 1 deletion pkg/edgevpn/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (e *EdgeVPN) genHost(ctx context.Context) (host.Host, error) {
}

func (e *EdgeVPN) sealkey() string {
return gotp.NewTOTP(e.config.ExchangeKey, 6, e.config.SealKeyInterval, nil).Now()
return gotp.NewTOTP(e.config.ExchangeKey, e.config.SealKeyLength, e.config.SealKeyInterval, nil).Now()
}

func (e *EdgeVPN) handleEvents(ctx context.Context) {
Expand Down
1 change: 1 addition & 0 deletions pkg/edgevpn/edgevpn.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func New(p ...Option) *EdgeVPN {
StreamHandlers: make(map[protocol.ID]StreamHandler),
LedgerAnnounceTime: 5 * time.Second,
LedgerSyncronizationTime: 5 * time.Second,
SealKeyLength: 12,
}
c.Apply(p...)

Expand Down

0 comments on commit 139c93d

Please sign in to comment.