Skip to content

Commit d5f3859

Browse files
committed
Add ctx
1 parent 52cd465 commit d5f3859

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

agent.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ func Run(ctx context.Context, configFilePath string, hostDNSServer DNSServer,
175175
return err
176176
}
177177

178-
go refreshDNSEntries(iptables, allowedEndpoints, &dnsProxy)
178+
go refreshDNSEntries(ctx, iptables, allowedEndpoints, &dnsProxy)
179179
}
180180

181181
WriteLog("done")
@@ -196,11 +196,13 @@ func Run(ctx context.Context, configFilePath string, hostDNSServer DNSServer,
196196
}
197197
}
198198

199-
func refreshDNSEntries(iptables *Firewall, allowedEndpoints map[string][]Endpoint, dnsProxy *DNSProxy) {
199+
func refreshDNSEntries(ctx context.Context, iptables *Firewall, allowedEndpoints map[string][]Endpoint, dnsProxy *DNSProxy) {
200200
ticker := time.NewTicker(30 * time.Second)
201201
go func() {
202202
for {
203203
select {
204+
case <-ctx.Done():
205+
return
204206
case <-ticker.C:
205207
WriteLog("Refreshing DNS entries")
206208
for domainName, endpoints := range allowedEndpoints {

firewall_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func Test_addAuditRules(t *testing.T) {
2727
endpoints := []ipAddressEndpoint{}
2828
endpoints = append(endpoints, ipAddressEndpoint{ipAddress: "1.1.1.1", port: "443"})
2929

30-
err = addBlockRulesForGitHubHostedRunner(endpoints)
30+
err = addBlockRulesForGitHubHostedRunner(nil, endpoints)
3131
if err != nil {
3232
t.Errorf("Error not expected %v", err)
3333
}

0 commit comments

Comments
 (0)