Skip to content

Commit 6a18ec5

Browse files
committed
decoy-registrar: add Send()
1 parent 7915c67 commit 6a18ec5

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

pkg/registrars/decoy-registrar/decoy-registrar.go

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,9 @@ import (
1212
"github.com/sirupsen/logrus"
1313
)
1414

15-
// Copied from dns-registrar
16-
var (
17-
ErrRegFailed = errors.New("registration failed")
18-
)
19-
20-
type DialFunc func(ctx context.Context, network, addr string) (net.Conn, error)
21-
2215
type DecoyRegistrar struct {
2316

24-
// dialContex is a custom dailer to use when establishing TCP connections
17+
// dialContex is a custom dialer to use when establishing TCP connections
2518
// to decoys. When nil, Dialer.dialContex will be used.
2619
dialContex DialFunc
2720

@@ -78,8 +71,7 @@ func (r DecoyRegistrar) Register(cjSession *tapdance.ConjureSession, ctx context
7871
for _, decoy := range decoys {
7972
logger.Debugf("Sending Reg: %v, %v", decoy.GetHostname(), decoy.GetIpAddrStr())
8073
//decoyAddr := decoy.GetIpAddrStr()
81-
// r.Send()
82-
go reg.Send(ctx, decoy, dialErrors)
74+
go r.Send(ctx, reg, decoy, dialErrors)
8375
}
8476

8577
//[reference] Dial errors happen immediately so block until all N dials complete
@@ -115,13 +107,13 @@ func (r DecoyRegistrar) Register(cjSession *tapdance.ConjureSession, ctx context
115107
return reg, nil
116108
}
117109

118-
func (r DecoyRegistrar) Send(ctx context.Context, decoy *pb.TLSDecoySpec, dialErrors chan error) {
110+
func (r DecoyRegistrar) Send(ctx context.Context, reg *tapdance.ConjureReg, decoy *pb.TLSDecoySpec, dialErrors chan error) {
119111
deadline, deadlineAlreadySet := ctx.Deadline()
120112

121113
if !deadlineAlreadySet {
122114
deadline = time.Now().Add(tapdance.GetRandomDuration(tapdance.deadlineTCPtoDecoyMin, tapdance.deadlineTCPtoDecoyMax))
123115
}
124-
116+
125117
childCtx, childCancelFunc := context.WithDeadline(ctx, deadline)
126118
defer childCancelFunc()
127119

0 commit comments

Comments
 (0)