mirror of
https://github.com/ZeroTier/ZeroTierOne
synced 2025-08-20 13:24:09 -07:00
.
This commit is contained in:
parent
e3d47e588a
commit
e5bd230fb0
15 changed files with 197 additions and 42 deletions
|
@ -16,9 +16,12 @@
|
|||
package zerotier
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
"time"
|
||||
)
|
||||
|
||||
func createNamedSocketListener(basePath, name string) (net.Listener, error) {
|
||||
|
@ -26,3 +29,17 @@ func createNamedSocketListener(basePath, name string) (net.Listener, error) {
|
|||
os.Remove(apiSockPath)
|
||||
return net.Listen("unix", apiSockPath)
|
||||
}
|
||||
|
||||
func createNamedSocketHTTPClient(basePath, name string) (*http.Client, error) {
|
||||
apiSockPath := path.Join(basePath, name)
|
||||
return &http.Client{
|
||||
Timeout: 10 * time.Second,
|
||||
Transport: &http.Transport{
|
||||
DialContext: func(_ context.Context, _, _ string) (net.Conn, error) {
|
||||
return net.Dial("unix", apiSockPath)
|
||||
},
|
||||
DisableKeepAlives: true,
|
||||
DisableCompression: true,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue