mirror of
https://github.com/fosrl/olm.git
synced 2026-02-08 05:56:41 +00:00
43
main.go
43
main.go
@@ -34,8 +34,15 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Handle service management commands on Windows
|
// Handle service management commands on Windows
|
||||||
if runtime.GOOS == "windows" && len(os.Args) > 1 {
|
if runtime.GOOS == "windows" {
|
||||||
switch os.Args[1] {
|
var command string
|
||||||
|
if len(os.Args) > 1 {
|
||||||
|
command = os.Args[1]
|
||||||
|
} else {
|
||||||
|
command = "default"
|
||||||
|
}
|
||||||
|
|
||||||
|
switch command {
|
||||||
case "install":
|
case "install":
|
||||||
err := installService()
|
err := installService()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -118,6 +125,7 @@ func main() {
|
|||||||
fmt.Println(" stop Stop the service")
|
fmt.Println(" stop Stop the service")
|
||||||
fmt.Println(" status Show service status")
|
fmt.Println(" status Show service status")
|
||||||
fmt.Println(" debug Run service in debug mode")
|
fmt.Println(" debug Run service in debug mode")
|
||||||
|
fmt.Println(" logs Tail the service log file")
|
||||||
fmt.Println("\nFor console mode, run without arguments or with standard flags.")
|
fmt.Println("\nFor console mode, run without arguments or with standard flags.")
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
@@ -373,6 +381,22 @@ func runOlmMainWithArgs(ctx context.Context, args []string) {
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
// Create a new olm
|
||||||
|
olm, err := websocket.NewClient(
|
||||||
|
"olm",
|
||||||
|
id, // CLI arg takes precedence
|
||||||
|
secret, // CLI arg takes precedence
|
||||||
|
endpoint,
|
||||||
|
pingInterval,
|
||||||
|
pingTimeout,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
logger.Fatal("Failed to create olm: %v", err)
|
||||||
|
}
|
||||||
|
endpoint = olm.GetConfig().Endpoint // Update endpoint from config
|
||||||
|
id = olm.GetConfig().ID // Update ID from config
|
||||||
|
secret = olm.GetConfig().Secret // Update secret from config
|
||||||
|
|
||||||
// wait until we have a client id and secret and endpoint
|
// wait until we have a client id and secret and endpoint
|
||||||
waitCount := 0
|
waitCount := 0
|
||||||
for id == "" || secret == "" || endpoint == "" {
|
for id == "" || secret == "" || endpoint == "" {
|
||||||
@@ -410,21 +434,6 @@ func runOlmMainWithArgs(ctx context.Context, args []string) {
|
|||||||
logger.Fatal("Failed to generate private key: %v", err)
|
logger.Fatal("Failed to generate private key: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new olm
|
|
||||||
olm, err := websocket.NewClient(
|
|
||||||
"olm",
|
|
||||||
id, // CLI arg takes precedence
|
|
||||||
secret, // CLI arg takes precedence
|
|
||||||
endpoint,
|
|
||||||
pingInterval,
|
|
||||||
pingTimeout,
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
logger.Fatal("Failed to create olm: %v", err)
|
|
||||||
}
|
|
||||||
endpoint = olm.GetConfig().Endpoint // Update endpoint from config
|
|
||||||
id = olm.GetConfig().ID // Update ID from config
|
|
||||||
|
|
||||||
// Create TUN device and network stack
|
// Create TUN device and network stack
|
||||||
var dev *device.Device
|
var dev *device.Device
|
||||||
var wgData WgData
|
var wgData WgData
|
||||||
|
|||||||
Reference in New Issue
Block a user