mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-02-03 22:18:39 +00:00
smol tweaks to nameserver test queries fix restoreDNS errors add some debugging information fix wront type in log msg set send logs command timeout to 5 mins when the runningIface is no longer up, attempt to find a new interface prefer default route, ignore non physical interfaces prefer default route, ignore non physical interfaces add max context timeout on performLeakingQuery with more debug logs
39 lines
817 B
Go
39 lines
817 B
Go
package cli
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
"net"
|
|
"net/http"
|
|
"time"
|
|
)
|
|
|
|
type controlClient struct {
|
|
c *http.Client
|
|
}
|
|
|
|
func newControlClient(addr string) *controlClient {
|
|
return &controlClient{c: &http.Client{
|
|
Transport: &http.Transport{
|
|
DialContext: func(ctx context.Context, _, _ string) (net.Conn, error) {
|
|
d := net.Dialer{}
|
|
return d.DialContext(ctx, "unix", addr)
|
|
},
|
|
},
|
|
Timeout: time.Second * 30,
|
|
}}
|
|
}
|
|
|
|
func (c *controlClient) post(path string, data io.Reader) (*http.Response, error) {
|
|
// for log/send, set the timeout to 5 minutes
|
|
if path == sendLogsPath {
|
|
c.c.Timeout = time.Minute * 5
|
|
}
|
|
return c.c.Post("http://unix"+path, contentTypeJson, data)
|
|
}
|
|
|
|
// deactivationRequest represents request for validating deactivation pin.
|
|
type deactivationRequest struct {
|
|
Pin int64 `json:"pin"`
|
|
}
|