-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhancement: windows now use named pipes for IPC instead of unix sock…
…ets to support Windows 10 < 1809
- Loading branch information
Showing
11 changed files
with
96 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
//go:build !windows | ||
|
||
package launcher_common | ||
|
||
import ( | ||
"os" | ||
"path" | ||
) | ||
|
||
func ConfigAdminIpcPath() string { | ||
return path.Join(os.TempDir(), configAdminIpcName) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package launcher_common | ||
|
||
func ConfigAdminIpcPath() string { | ||
return `\\.\pipe\` + configAdminIpcName | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
//go:build !windows | ||
|
||
package internal | ||
|
||
import ( | ||
launcherCommon "github.com/luskaner/ageLANServer/launcher-common" | ||
"net" | ||
"os" | ||
) | ||
|
||
func SetupIpcServer() (listener net.Listener, err error) { | ||
ipcPath := launcherCommon.ConfigAdminIpcPath() | ||
|
||
if err = os.Remove(ipcPath); err != nil && !os.IsNotExist(err) { | ||
return | ||
} | ||
|
||
listener, err = net.Listen("unix", ipcPath) | ||
|
||
if err != nil { | ||
return | ||
} | ||
|
||
err = os.Chmod(ipcPath, 0666) | ||
return | ||
} | ||
|
||
func RevertIpcServer() { | ||
_ = os.Remove(launcherCommon.ConfigAdminIpcPath()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package internal | ||
|
||
import ( | ||
"fmt" | ||
"github.com/Microsoft/go-winio" | ||
launcherCommon "github.com/luskaner/ageLANServer/launcher-common" | ||
"net" | ||
"os/user" | ||
) | ||
|
||
func SetupIpcServer() (listener net.Listener, err error) { | ||
var u *user.User | ||
u, err = user.Current() | ||
if err != nil { | ||
return nil, err | ||
} | ||
pc := &winio.PipeConfig{ | ||
InputBufferSize: 1_024, | ||
OutputBufferSize: 1, | ||
SecurityDescriptor: fmt.Sprintf("D:P(A;;GA;;;%s)", u.Uid), | ||
MessageMode: true, | ||
} | ||
return winio.ListenPipe(launcherCommon.ConfigAdminIpcPath(), pc) | ||
} | ||
|
||
func RevertIpcServer() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,14 @@ | ||
package internal | ||
|
||
import ( | ||
"github.com/Microsoft/go-winio" | ||
launcherCommon "github.com/luskaner/ageLANServer/launcher-common" | ||
"net" | ||
) | ||
|
||
func preAgentStart() {} | ||
func postAgentStart(_ string) {} | ||
|
||
func DialIPC() (net.Conn, error) { | ||
return winio.DialPipe(launcherCommon.ConfigAdminIpcPath(), nil) | ||
} |