Skip to content

Commit

Permalink
fix: ipc connect on posix, provide http client and conn
Browse files Browse the repository at this point in the history
  • Loading branch information
go-compile committed Jul 22, 2023
1 parent a616b74 commit 1651cf1
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions cmd/localrelay/ipc_posix.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,24 @@ var (
ipcPathPrefix = "/var/run/"
)

func IPCConnect() (io.ReadWriteCloser, error) {
return net.DialTimeout("unix", ipcPathPrefix+ipcSocket, ipcTimeout)
func IPCConnect() (*http.Client, net.Conn, error) {
conn, err := net.DialTimeout("unix", ipcPathPrefix+ipcSocket, ipcTimeout)
if err != nil {
return nil, nil, err
}

// make a http client which always uses the socket.
// When making a HTTP request provide any host, it does not need to exist.
//
// Example:
// http://lr/status
httpClient := &http.Client{
Transport: &http.Transport{Dial: func(network, addr string) (net.Conn, error) {
return conn, nil
}},
}

return httpClient, conn, nil
}

func IPCListen() error {
Expand Down

0 comments on commit 1651cf1

Please sign in to comment.