Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows build #779

Merged
merged 67 commits into from
Nov 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
7ba4a95
wip windows build
alexadhy May 27, 2021
6733324
fixes *nix build
alexadhy May 27, 2021
895d4a8
fix linters windows
alexadhy May 27, 2021
7f1d35d
uses cmdutil from https://github.com/skycoin/dmsg/pull/83
alexadhy May 29, 2021
5dd3f81
fixes goimports
alexadhy May 29, 2021
cb0ca00
Merge remote-tracking branch 'upstream/develop' into windows-build
alexadhy May 29, 2021
2b34341
fixes windows closing file error, fixes data race in logstore
alexadhy May 31, 2021
234013a
update travis golangci-lint version
alexadhy May 31, 2021
fd9df42
goimports
alexadhy May 31, 2021
0a2b000
Merge remote-tracking branch 'upstream/develop' into windows-build
alexadhy Jun 13, 2021
83b2de6
Merge remote-tracking branch 'upstream/develop' into windows-build
alexadhy Jun 21, 2021
8c0ff8c
build with dmsgpty PR
alexadhy Jun 22, 2021
f7eb368
makefile fixes
alexadhy Jun 22, 2021
49ab591
Windows build
alexadhy Jun 22, 2021
30dbf40
added hypervisor dmsgpty for windows
alexadhy Jun 22, 2021
8e00ff3
fixes makefile build on *nix
alexadhy Jun 22, 2021
6365ab1
Merge remote-tracking branch 'upstream/develop' into windows-build
alexadhy Aug 26, 2021
0283e59
Merge remote-tracking branch 'upstream/develop' into windows-build
alexadhy Sep 7, 2021
5257972
Fixes windows start visor
alexadhy Sep 7, 2021
9bf21a9
fixes config loading for windows
alexadhy Sep 7, 2021
761f2b1
adjust default config for cli address in windows
alexadhy Sep 7, 2021
48d6bdc
fixes formatting, config, and socket unlink
alexadhy Sep 7, 2021
1a2ca5c
Merge remote-tracking branch 'upstream/develop' into windows-build
alexadhy Sep 7, 2021
b91455d
fixes formatting in windows
alexadhy Sep 7, 2021
db8d9de
fixes restart test and hypervisor test windows
alexadhy Sep 7, 2021
b8d4cf8
fixes hypervisor test
alexadhy Sep 7, 2021
752e488
lint
alexadhy Sep 7, 2021
5ef1d23
formatting and appveyor fixes
alexadhy Sep 8, 2021
da18891
formatting fixes
alexadhy Sep 8, 2021
5360164
Makefile: appveyor specific
alexadhy Sep 8, 2021
d3a1055
TODO:fixes non deterministic dmsgtracker on windows
alexadhy Sep 8, 2021
23d671d
Merge remote-tracking branch 'upstream/develop' into windows-build
alexadhy Sep 9, 2021
a03438a
some more fixes for windows
alexadhy Sep 10, 2021
bd7acc9
forced: requested changes
alexadhy Oct 2, 2021
215bbd0
Merge remote-tracking branch 'upstream/develop' into windows-build
alexadhy Oct 2, 2021
12dd99e
fixes formatting and vendoring
alexadhy Oct 2, 2021
852a7a9
merge upstream, fixes conflicts
alexadhy Oct 12, 2021
1b1b417
formatting fixes
alexadhy Oct 12, 2021
f30408e
make vpn-client works with windows
alexadhy Oct 12, 2021
080acfb
Merge remote-tracking branch 'upstream/develop' into windows-build
alexadhy Oct 13, 2021
514fa4e
signals aren't sendable on windows
alexadhy Oct 13, 2021
fd1068d
signals aren't sendable on windows
alexadhy Oct 13, 2021
4095a69
update vendor
alexadhy Oct 13, 2021
9d1ae67
wintun 0.14 API
alexadhy Oct 13, 2021
74d9e93
update docs
alexadhy Oct 13, 2021
2243e39
merge with develop, fixes merge conflict
alexadhy Oct 22, 2021
3cb9998
frontend stuff
alexadhy Oct 22, 2021
5541ce4
fixes merge conflicts, sync to develop
alexadhy Oct 22, 2021
67b16a3
fixes makefile
alexadhy Oct 22, 2021
5e9843c
Merge branch 'windows-build' of https://github.com/alexadhy/skywire i…
alexadhy Oct 22, 2021
62a261b
fixes windows build
alexadhy Oct 22, 2021
b74d4d0
enable dmsgpty route on windows
alexadhy Oct 25, 2021
c2f146f
merge with develop fixes conflict
alexadhy Nov 4, 2021
12d0138
update wintun dependency
alexadhy Nov 10, 2021
549c296
merge develop changes
alexadhy Nov 13, 2021
d2d5f5d
vpn-client added named pipes for shutting down in windows
alexadhy Nov 13, 2021
5eac2fd
fixes ipc shutdown windows
alexadhy Nov 13, 2021
c598093
fixes panic in shutdown vpn
alexadhy Nov 13, 2021
07ba357
ipc socket for all apps
alexadhy Nov 13, 2021
ea0b8e0
fixes panic on vpn-client
alexadhy Nov 17, 2021
a27ae50
Merge remote-tracking branch 'upstream/develop' into windows-build
alexadhy Nov 22, 2021
0fb18e5
fixes appveyor lint issues
alexadhy Nov 22, 2021
2fd4638
update cobra to latest version
alexadhy Nov 22, 2021
7c1471c
fixes makefile for windows, remove redirection to dev/null
alexadhy Nov 23, 2021
ba2678c
makefile changes
alexadhy Nov 23, 2021
3aaa550
merge with develop, fixes merge conflict
alexadhy Nov 29, 2021
a21c0c8
merge with develop, fixes merge conflict
alexadhy Nov 29, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
87 changes: 83 additions & 4 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,32 @@ environment:
appveyor_build_worker_image: ubuntu1804
GOARCH: amd64
- job_name: MacOS
appveyor_build_worker_image: macos
appveyor_build_worker_image: macos-bigsur
GOARCH: amd64
- job_name: Windows
appveyor_build_worker_image: Visual Studio 2019
GOARCH: amd64

# For release, by pushing tag
- job_name: linux-amd64
appveyor_build_worker_image: ubuntu2004
GOARCH: amd64
- job_name: linux-arm
appveyor_build_worker_image: ubuntu2004
GOARCH: arm
- job_name: linux-arm64
appveyor_build_worker_image: ubuntu2004
GOARCH: arm64
- job_name: linux-386
appveyor_build_worker_image: ubuntu2004
GOARCH: 386
- job_name: darwin-amd64
appveyor_build_worker_image: macos
GOARCH: amd64
- job_name: windows-amd64
appveyor_build_worker_image: Visual Studio 2019
GOARCH: amd64

for:
- # Linux and MacOS
skip_tags: true
Expand Down Expand Up @@ -43,12 +66,68 @@ for:

install:
- choco install make
- go get github.com/golangci/golangci-lint/cmd/[email protected]
- go install github.com/golangci/golangci-lint/cmd/[email protected]
- make dep

- make install-deps-ui
- set PATH=C:\Users\appveyor\go\bin;C:\msys64\mingw64\bin;C:\msys64\usr\bin;%PATH%

before_build:
- set GO111MODULE=on
- make check-windows-appveyor
- make check-windows
- make lint-ui

build_script:
- make build-windows
- make build-ui-windows

- # Linux and MacOS (Release)
skip_non_tags: true
matrix:
only:
- job_name: linux-arm
- job_name: linux-arm64
- job_name: linux-amd64
- job_name: linux-386
- job_name: darwin-amd64

install:
- make dep
- ci_scripts/create-ip-aliases.sh
- export GOARM=7

build_script:
- make build

after_build:
- tar -cvzf skywire-$APPVEYOR_REPO_TAG_NAME-$APPVEYOR_JOB_NAME.tar.gz ./apps/* ./skywire-visor ./skywire-cli ./setup-node

artifacts:
- path: skywire-$(APPVEYOR_REPO_TAG_NAME)-$(APPVEYOR_JOB_NAME).tar.gz
name: deploy

deploy:
- provider: GitHub
release: $(APPVEYOR_REPO_TAG_NAME)
auth_token:
secure: ZrbNBE2wSfGvHzEq5GqEAUmNy7myDIl7KK05CKlZdQfieV7XdIAPXpkdHNEyZbvT
draft: true
artifact: deploy
on:
APPVEYOR_REPO_TAG: true

- # Windows (Release)
skip_non_tags: true
matrix:
only:
- job_name: windows-amd64

environment:
matrix:
- GOARCH: amd64

install:
- cmd: choco install make
- make dep

build_script:
- make build
115 changes: 91 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.DEFAULT_GOAL := help

.PHONY : check lint install-linters dep test
.PHONY : build clean install format bin
Expand All @@ -7,18 +6,26 @@
.PHONY : docker-apps docker-bin docker-volume
.PHONY : docker-run docker-stop

SHELL := /bin/bash
VERSION ?= $(shell git describe 2> /dev/null)
#VERSION := v0.1.0 # for debugging updater

VERSION := $(shell git describe)
RFC_3339 := "+%Y-%m-%dT%H:%M:%SZ"
DATE := $(shell date -u $(RFC_3339))
COMMIT ?= $(shell git rev-list -1 HEAD 2> /dev/null)
COMMIT := $(shell git rev-list -1 HEAD)
BRANCH := latest


PROJECT_BASE := github.com/skycoin/skywire
DMSG_BASE := github.com/skycoin/dmsg
OPTS?=GO111MODULE=on
ifeq ($(OS),Windows_NT)
SHELL := pwsh
OPTS?=powershell -Command setx GO111MODULE on;
DATE := $(shell powershell -Command date -u ${RFC_3339})
.DEFAULT_GOAL := help-windows
else
SHELL := /bin/bash
OPTS?=GO111MODULE=on
Copy link
Contributor

@ersonp ersonp Sep 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to use DATE := $(shell date -u $(RFC_3339)) inside the else.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's already a DATE variable defined above, so no need to define it twice

Copy link
Contributor

@ersonp ersonp Sep 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, what I meant was that DATE := $(shell date -u $(RFC_3339)) should be inside the else statement as make isn't working in windows if it is outside.

DATE := $(shell date -u $(RFC_3339))
.DEFAULT_GOAL := help
endif

STATIC_OPTS?= $(OPTS) CC=musl-gcc
MANAGER_UI_DIR = static/skywire-manager-src
GO_BUILDER_VERSION=v1.17
Expand Down Expand Up @@ -46,10 +53,16 @@ BUILD_OPTS_DEPLOY?="-ldflags=$(BUILDINFO) -w -s"

check: lint test ## Run linters and tests

check-windows: lint-windows test-windows ## Run linters and tests on appveyor windows image

build: host-apps bin ## Install dependencies, build apps and binaries. `go build` with ${OPTS}

build-windows: host-apps-windows bin-windows ## Install dependencies, build apps and binaries. `go build` with ${OPTS}

build-systray: host-apps-systray bin-systray ## Install dependencies, build apps and binaries `go build` with ${OPTS}, with CGO and systray

build-systray-windows: host-apps-systray-windows bin-systray-windows ## Builds systray binary in windows

build-static: host-apps-static bin-static ## Build apps and binaries. `go build` with ${OPTS}

installer: mac-installer ## Builds MacOS installer for skywire-visor
Expand All @@ -65,24 +78,46 @@ clean: ## Clean project: remove created binaries and apps
-rm -rf ./apps
-rm -f ./skywire-visor ./skywire-cli ./setup-node

clean-windows: ## Clean project: remove created binaries and apps
powershell -Command Remove-Item -Path ./apps -Force -Recurse
powershell -Command Remove-Item -Path .\skywire-visor.exe,.\skywire-cli.exe,.\setup-node.exe -Force

install: ## Install `skywire-visor`, `skywire-cli`, `setup-node`
${OPTS} go install ${BUILD_OPTS} ./cmd/skywire-visor ./cmd/skywire-cli ./cmd/setup-node

install-windows: ## Install `skywire-visor`, `skywire-cli`, `setup-node`
powershell 'Get-ChildItem .\cmd | % { ${OPTS} go install ${BUILD_OPTS} ./ $$_.FullName }'

install-static: ## Install `skywire-visor`, `skywire-cli`, `setup-node`
${STATIC_OPTS} go install -trimpath --ldflags '-linkmode external -extldflags "-static" -buildid=' ./cmd/skywire-visor ./cmd/skywire-cli ./cmd/setup-node

lint: ## Run linters. Use make install-linters first
${OPTS} golangci-lint run -c .golangci.yml ./...

lint-windows: ## Run linters. Use make install-linters-windows first
powershell 'golangci-lint run -c .golangci.yml ./...'

lint-appveyor-windows: ## Run linters for appveyor only on windows
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is giving an error

PS C:\Users\Erson\skywire> make lint-appveyor-windows
C:\Users\appveyor\go\bin\golangci-lint run -c .golangci.yml ./...
process_begin: CreateProcess(NULL, C:\Users\appveyor\go\bin\golangci-lint run -c .golangci.yml ./..., ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [Makefile:106: lint-appveyor-windows] Error 2

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tried to add golangci-lint to your own %PATH%, because that one is for appveyor

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and you should've run make check-windows

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. Was just testing all the commands. Everything else works then.

C:\Users\appveyor\go\bin\golangci-lint run -c .golangci.yml ./...

test: ## Run tests
-go clean -testcache &>/dev/null
${OPTS} go test ${TEST_OPTS} ./internal/...
${OPTS} go test ${TEST_OPTS} ./pkg/...

test-windows: ## Run tests on windows
@go clean -testcache
${OPTS} go test ${TEST_OPTS} ./internal/...
${OPTS} go test ${TEST_OPTS} ./pkg/...

install-linters: ## Install linters
- VERSION=latest ./ci_scripts/install-golangci-lint.sh
${OPTS} go get -u golang.org/x/tools/cmd/goimports
${OPTS} go get -u github.com/incu6us/goimports-reviser/v2
${OPTS} go install golang.org/x/tools/cmd/goimports@latest
${OPTS} go install github.com/incu6us/goimports-reviser/v2@latest

install-linters-windows: ## Install linters
${OPTS} go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
${OPTS} go install golang.org/x/tools/cmd/goimports@latest

tidy: ## Tidies and vendors dependencies.
${OPTS} go mod tidy -v
Expand All @@ -93,6 +128,9 @@ format: tidy ## Formats the code. Must have goimports and goimports-reviser inst
${OPTS} goimports -w -local ${PROJECT_BASE} ./internal
find . -type f -name '*.go' -not -path "./.git/*" -not -path "./vendor/*" -exec goimports-reviser -project-name ${PROJECT_BASE} -file-path {} \;

format-windows: tidy ## Formats the code. Must have goimports and goimports-reviser installed (use make install-linters).
powershell 'Get-ChildItem -Directory | where Name -NotMatch vendor | % { Get-ChildItem $$_ -Recurse -Include *.go } | % {goimports -w -local ${PROJECT_BASE} $$_ }'

dep: tidy ## Sorts dependencies
${OPTS} go mod vendor -v

Expand All @@ -103,11 +141,16 @@ snapshot-clean: ## Cleans snapshot / release
rm -rf ./dist

host-apps: ## Build app
${OPTS} go build ${BUILD_OPTS} -o ./apps/skychat ./cmd/apps/skychat
${OPTS} go build ${BUILD_OPTS} -o ./apps/skysocks ./cmd/apps/skysocks
${OPTS} go build ${BUILD_OPTS} -o ./apps/skysocks-client ./cmd/apps/skysocks-client
${OPTS} go build ${BUILD_OPTS} -o ./apps/vpn-server ./cmd/apps/vpn-server
${OPTS} go build ${BUILD_OPTS} -o ./apps/vpn-client ./cmd/apps/vpn-client
mkdir -p ./apps
${OPTS} go build ${BUILD_OPTS} -o ./apps/ ./cmd/apps/skychat
${OPTS} go build ${BUILD_OPTS} -o ./apps/ ./cmd/apps/skysocks
${OPTS} go build ${BUILD_OPTS} -o ./apps/ ./cmd/apps/skysocks-client
${OPTS} go build ${BUILD_OPTS} -o ./apps/ ./cmd/apps/vpn-server
${OPTS} go build ${BUILD_OPTS} -o ./apps/ ./cmd/apps/vpn-client

host-apps-windows:
powershell -Command new-item .\apps -itemtype directory -force
powershell 'Get-ChildItem .\cmd\apps | % { ${OPTS} go build ${BUILD_OPTS} -o ./apps $$_.FullName }'

host-apps-systray: ## Build app
${OPTS} go build ${BUILD_OPTS} -o ./apps/skychat ./cmd/apps/skychat
Expand All @@ -116,21 +159,36 @@ host-apps-systray: ## Build app
${OPTS} go build ${BUILD_OPTS} -tags systray -o ./apps/vpn-server ./cmd/apps/vpn-server
${OPTS} go build ${BUILD_OPTS} -tags systray -o ./apps/vpn-client ./cmd/apps/vpn-client

host-apps-systray-windows:
powershell -Command new-item .\apps -itemtype directory -force
powershell 'go build ${BUILD_OPTS} -o .\apps\skychat .\cmd\apps\skychat'
powershell 'go build ${BUILD_OPTS} -o .\apps\skysocks .\cmd\apps\skysocks'
powershell 'go build ${BUILD_OPTS} -o .\apps\skysocks-client .\cmd\apps\skysocks-client'
powershell 'go build ${BUILD_OPTS} -tags systray -o .\apps\vpn-server .\cmd\apps\vpn-server'
powershell 'go build ${BUILD_OPTS} -tags systray -o .\apps\vpn-client .\cmd\apps\vpn-client'

# Static Apps
host-apps-static: ## Build app
${STATIC_OPTS} go build -trimpath --ldflags '-linkmode external -extldflags "-static" -buildid=' -o ./apps/skychat ./cmd/apps/skychat
${STATIC_OPTS} go build -trimpath --ldflags '-linkmode external -extldflags "-static" -buildid=' -o ./apps/skysocks ./cmd/apps/skysocks
${STATIC_OPTS} go build -trimpath --ldflags '-linkmode external -extldflags "-static" -buildid=' -o ./apps/skysocks-client ./cmd/apps/skysocks-client
${STATIC_OPTS} go build -trimpath --ldflags '-linkmode external -extldflags "-static" -buildid=' -o ./apps/vpn-server ./cmd/apps/vpn-server
${STATIC_OPTS} go build -trimpath --ldflags '-linkmode external -extldflags "-static" -buildid=' -o ./apps/vpn-client ./cmd/apps/vpn-client
mkdir -p ./apps
${STATIC_OPTS} go build -trimpath --ldflags '-linkmode external -extldflags "-static" -buildid=' -o ./apps/ ./cmd/apps/skychat
${STATIC_OPTS} go build -trimpath --ldflags '-linkmode external -extldflags "-static" -buildid=' -o ./apps/ ./cmd/apps/skysocks
${STATIC_OPTS} go build -trimpath --ldflags '-linkmode external -extldflags "-static" -buildid=' -o ./apps/ ./cmd/apps/skysocks-client
${STATIC_OPTS} go build -trimpath --ldflags '-linkmode external -extldflags "-static" -buildid=' -o ./apps/ ./cmd/apps/vpn-server
${STATIC_OPTS} go build -trimpath --ldflags '-linkmode external -extldflags "-static" -buildid=' -o ./apps/ ./cmd/apps/vpn-client

# Bin
bin: ## Build `skywire-visor`, `skywire-cli`
${OPTS} go build ${BUILD_OPTS} -o ./skywire-visor ./cmd/skywire-visor
${OPTS} go build ${BUILD_OPTS} -o ./skywire-cli ./cmd/skywire-cli
${OPTS} go build ${BUILD_OPTS} -o ./setup-node ./cmd/setup-node
${OPTS} go build ${BUILD_OPTS} -o ./ ./cmd/skywire-visor
${OPTS} go build ${BUILD_OPTS} -o ./ ./cmd/skywire-cli
${OPTS} go build ${BUILD_OPTS} -o ./ ./cmd/setup-node

bin-windows: ## Build `skywire-visor`, `skywire-cli`
powershell 'Get-ChildItem .\cmd | % { ${OPTS} go build ${BUILD_OPTS} -o ./ $$_.FullName }'

bin-systray-windows: ## Build `skywire-visor` and `skywire-cli` with systray support
powershell 'Get-ChildItem .\cmd | % { ${OPTS} go build ${BUILD_OPTS} -tags systray -o ./ $$_.FullName }'

bin-systray:
bin-systray: ## Build `skywire-visor`, `skywire-cli`
${OPTS} go build ${BUILD_OPTS} -tags systray -o ./skywire-visor ./cmd/skywire-visor
${OPTS} go build ${BUILD_OPTS} -tags systray -o ./skywire-cli ./cmd/skywire-cli
${OPTS} go build ${BUILD_OPTS} -o ./setup-node ./cmd/setup-node
Expand Down Expand Up @@ -174,6 +232,12 @@ build-ui: install-deps-ui ## Builds the UI
mkdir ${MANAGER_UI_BUILT_DIR}
cp -r ${MANAGER_UI_DIR}/dist/. ${MANAGER_UI_BUILT_DIR}

build-ui-windows: install-deps-ui ## Builds the UI on windows
cd $(MANAGER_UI_DIR) && npm run build
powershell 'Remove-Item -Recurse -Force -Path ${MANAGER_UI_BUILT_DIR}'
powershell 'New-Item -Path ${MANAGER_UI_BUILT_DIR} -ItemType Directory'
powershell 'Copy-Item -Recurse ${MANAGER_UI_DIR}\dist\* ${MANAGER_UI_BUILT_DIR}'

deb-install-prequisites: ## Create unsigned application
sudo chmod +x ./scripts/deb_installer/prequisites.sh
./scripts/deb_installer/prequisites.sh
Expand All @@ -192,3 +256,6 @@ mac-installer-help: ## Show installer creation help

help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

help-windows: ## Display help for windows
@powershell 'Select-String -Pattern "windows[a-zA-Z_-]*:.*## .*$$" $(MAKEFILE_LIST) | % { $$_.Line -split ":.*?## " -Join "`t:`t" } '
26 changes: 26 additions & 0 deletions cmd/apps/skychat/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ import (
"net"
"net/http"
"os"
"runtime"
"sync"
"time"

ipc "github.com/james-barrow/golang-ipc"
"github.com/skycoin/dmsg/buildinfo"
"github.com/skycoin/dmsg/cipher"
"github.com/skycoin/skycoin/src/util/logging"
Expand All @@ -23,6 +25,7 @@ import (
"github.com/skycoin/skywire/pkg/app"
"github.com/skycoin/skywire/pkg/app/appnet"
"github.com/skycoin/skywire/pkg/routing"
"github.com/skycoin/skywire/pkg/skyenv"
)

const (
Expand Down Expand Up @@ -63,6 +66,15 @@ func main() {
conns = make(map[cipher.PubKey]net.Conn)
go listenLoop()

if runtime.GOOS == "windows" {
ipcClient, err := ipc.StartClient(skyenv.SkychatName, nil)
if err != nil {
fmt.Printf("Error creating ipc server for skychat client: %v\n", err)
os.Exit(1)
}
go handleIPCSignal(ipcClient)
}

http.Handle("/", http.FileServer(getFileSystem()))
http.HandleFunc("/message", messageHandler)
http.HandleFunc("/sse", sseHandler)
Expand Down Expand Up @@ -215,3 +227,17 @@ func getFileSystem() http.FileSystem {
}
return http.FS(fsys)
}

func handleIPCSignal(client *ipc.Client) {
for {
m, err := client.Read()
if err != nil {
fmt.Printf("%s IPC received error: %v", skyenv.SkychatName, err)
}
if m.MsgType == skyenv.IPCShutdownMessageType {
fmt.Println("Stopping " + skyenv.SkychatName + " via IPC")
break
}
}
os.Exit(0)
}
Loading