mirror of
https://github.com/jwhited/wgsd.git
synced 2025-01-18 13:59:34 +08:00
add timeout to wgsd-client
This commit is contained in:
parent
6bb19aedf6
commit
e9812b0947
@ -11,6 +11,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/miekg/dns"
|
"github.com/miekg/dns"
|
||||||
"golang.zx2c4.com/wireguard/wgctrl"
|
"golang.zx2c4.com/wireguard/wgctrl"
|
||||||
@ -60,7 +61,9 @@ func main() {
|
|||||||
done := make(chan struct{})
|
done := make(chan struct{})
|
||||||
go func() {
|
go func() {
|
||||||
defer close(done)
|
defer close(done)
|
||||||
dnsClient := &dns.Client{}
|
dnsClient := &dns.Client{
|
||||||
|
Timeout: time.Second * 5,
|
||||||
|
}
|
||||||
for _, peer := range wgDevice.Peers {
|
for _, peer := range wgDevice.Peers {
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
@ -128,7 +131,7 @@ func main() {
|
|||||||
err = wgClient.ConfigureDevice(*deviceFlag, deviceConfig)
|
err = wgClient.ConfigureDevice(*deviceFlag, deviceConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf(
|
log.Printf(
|
||||||
"failed to configure peer %s on %s, error: %v",
|
"[%s] failed to configure peer on %s, error: %v",
|
||||||
pubKeyBase64, *deviceFlag, err)
|
pubKeyBase64, *deviceFlag, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user