mirror of
https://github.com/yusing/godoxy.git
synced 2025-07-27 06:03:16 +02:00
Merge branch 'feat/proxmox-idlewatcher' into feat/custom-json-marshaling
This commit is contained in:
parent
c2b606e63e
commit
feb9947543
2 changed files with 7 additions and 5 deletions
|
@ -58,12 +58,17 @@ func Ping(ctx context.Context, ip net.IP) (bool, error) {
|
||||||
}
|
}
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
|
||||||
|
err = conn.SetWriteDeadline(time.Now().Add(5 * time.Second))
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
_, err = conn.WriteTo(msgBytes, &net.IPAddr{IP: ip})
|
_, err = conn.WriteTo(msgBytes, &net.IPAddr{IP: ip})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = conn.SetReadDeadline(time.Now().Add(1 * time.Second))
|
err = conn.SetReadDeadline(time.Now().Add(5 * time.Second))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
@ -90,7 +95,7 @@ func Ping(ctx context.Context, ip net.IP) (bool, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var pingDialer = &net.Dialer{
|
var pingDialer = &net.Dialer{
|
||||||
Timeout: 1 * time.Second,
|
Timeout: 2 * time.Second,
|
||||||
}
|
}
|
||||||
|
|
||||||
// PingWithTCPFallback pings the IP address using ICMP and TCP fallback.
|
// PingWithTCPFallback pings the IP address using ICMP and TCP fallback.
|
||||||
|
|
|
@ -42,9 +42,6 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
func (n *Node) LXCAction(ctx context.Context, vmid int, action LXCAction) error {
|
func (n *Node) LXCAction(ctx context.Context, vmid int, action LXCAction) error {
|
||||||
ctx, cancel := context.WithTimeout(ctx, proxmoxReqTimeout)
|
|
||||||
defer cancel()
|
|
||||||
|
|
||||||
var upid proxmox.UPID
|
var upid proxmox.UPID
|
||||||
if err := n.client.Post(ctx, fmt.Sprintf("/nodes/%s/lxc/%d/status/%s", n.name, vmid, action), nil, &upid); err != nil {
|
if err := n.client.Post(ctx, fmt.Sprintf("/nodes/%s/lxc/%d/status/%s", n.name, vmid, action), nil, &upid); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Add table
Reference in a new issue