Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
reddec committed May 18, 2020
1 parent 3a9c53d commit e2734c6
Show file tree
Hide file tree
Showing 30 changed files with 1,471 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
assets/** filter=lfs diff=lfs merge=lfs -text
118 changes: 118 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: Build app
on:
push:
tags:
- 'v*'
jobs:

linux:
name: Build for linux and windows
runs-on: ubuntu-latest
steps:
- name: Install dependencies
run: sudo apt-get install -y libgl1-mesa-dev xorg-dev make
- name: Set up Go 1.13
uses: actions/setup-go@v1
with:
go-version: 1.13
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: Make linux
run: make linux
- uses: actions/upload-artifact@v2
with:
name: linux-build
path: build/tinc-desktop-linux64.tar.gz

macosx:
name: Build for MacOSx
runs-on: macos-latest
steps:
- name: Set up Go 1.13
uses: actions/setup-go@v1
with:
go-version: 1.13
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: Make darwin
run: make darwin
- uses: actions/upload-artifact@v2
with:
name: darwin-build
path: build/tinc-desktop-darwin64.tar.gz

windows:
name: Build for windows
runs-on: windows-latest
steps:
- name: Set up Go 1.13
uses: actions/setup-go@v1
with:
go-version: 1.13
id: go
- uses: numworks/setup-msys2@v1
- name: Install dependencies
run: msys2do pacman --noconfirm -S make
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: Make darwin
run: msys2do make darwin
- uses: actions/upload-artifact@v2
with:
name: darwin-build
path: build/tinc-desktop-win64.tar.gz

release:
name: Release artifacts
runs-on: ubuntu-latest
needs:
- windows
- linux
- darwin
steps:
- uses: actions/download-artifact@v2

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Upload Linux Release
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./tinc-desktop-linux64.tar.gz
asset_name: tinc-desktop-linux64.tar.gz
asset_content_type: application/tar+gzip

- name: Upload Darwin Release
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./tinc-desktop-darwin64.tar.gz
asset_name: tinc-desktop-darwin64.tar.gz
asset_content_type: application/tar+gzip

- name: Upload Windows Release
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./tinc-desktop-win64.tar.gz
asset_name: tinc-desktop-win64.tar.gz
asset_content_type: application/tar+gzip
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/fyne-cross
/build
/.idea
/icon.png
54 changes: 54 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
export PATH := $(shell go env GOPATH)/bin:$(PATH)

all: clean install

fyne:
ifeq (, $(shell which fyne))
go get -v fyne.io/fyne/cmd/fyne
else
@echo "fyne installed"
endif

fyne-cross-bin:
ifeq (, $(shell which fyne-cross))
go get -v github.com/lucor/fyne-cross/cmd/fyne-cross
else
@echo "fyne-cross installed"
endif

rsrc:
ifeq (, $(shell which rsrc))
go get -v github.com/akavel/rsrc
else
@echo "rsrc installed"
endif

clean:
rm -rf build

build:
mkdir -p build

linux: build
mkdir -p build/linux
go build -ldflags "-s -w" -trimpath -v -o build/linux/tinc-desktop ./cmd/tinc-desktop
cd build/linux && tar -zcvf ../tinc-desktop-linux64.tar.gz .

windows: build rsrc
mkdir -p build/windows
rm -rf fyne-cross
rsrc -manifest assets/admin.xml -o tinc-desktop.syso
go build -ldflags "-s -w" -H=windowsgui -trimpath -v -o build/windows/tinc-desktop.exe ./cmd/tinc-desktop
rm tinc-desktop.syso
cp -r assets/windows/. build/windows/
cd build/windows && zip -r ../tinc-desktop-win64.zip .

darwin: build
mkdir -p build/darwin
go build -ldflags "-s -w" -trimpath -v -o build/darwin/tinc-desktop ./cmd/tinc-desktop
cd build/darwin && tar -zcvf ../tinc-desktop-darwin64.tar.gz .


install: linux windows darwin

.PHONY: all
23 changes: 23 additions & 0 deletions api/tincwebmajordomo/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package tincwebmajordomo

import (
"context"
client "github.com/reddec/jsonrpc2/client"
network "github.com/tinc-boot/tincd/network"
"sync/atomic"
)

func Default() *TincWebMajordomoClient {
return &TincWebMajordomoClient{BaseURL: "http://127.0.0.1:8686/api/"}
}

type TincWebMajordomoClient struct {
BaseURL string
sequence uint64
}

// Join public network if code matched. Will generate error if node subnet not matched
func (impl *TincWebMajordomoClient) Join(ctx context.Context, network string, self *network.Node) (reply *Sharing, err error) {
err = client.CallHTTP(ctx, impl.BaseURL, "TincWebMajordomo.Join", atomic.AddUint64(&impl.sequence, 1), &reply, network, self)
return
}
21 changes: 21 additions & 0 deletions api/tincwebmajordomo/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package tincwebmajordomo

import "github.com/tinc-boot/tincd/network"

type Network struct {
Name string `json:"name"`
Running bool `json:"running"`
Config *network.Config `json:"config,omitempty"` // only for specific request
}

type PeerInfo struct {
Name string `json:"name"`
Online bool `json:"online"`
Configuration network.Node `json:"config"`
}

type Sharing struct {
Name string `json:"name"`
Subnet string `json:"subnet"`
Nodes []*network.Node `json:"node,omitempty"`
}
3 changes: 3 additions & 0 deletions assets/admin.xml
Git LFS file not shown
3 changes: 3 additions & 0 deletions assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/windows/tap-win64/OemWin2k.inf
Git LFS file not shown
3 changes: 3 additions & 0 deletions assets/windows/tap-win64/tap0901.cat
Git LFS file not shown
3 changes: 3 additions & 0 deletions assets/windows/tap-win64/tap0901.sys
Git LFS file not shown
3 changes: 3 additions & 0 deletions assets/windows/tap-win64/tapinstall.exe
Git LFS file not shown
3 changes: 3 additions & 0 deletions assets/windows/tincd.exe
Git LFS file not shown
28 changes: 28 additions & 0 deletions cmd/tinc-desktop/internal/api/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package api

import (
"context"
client "github.com/reddec/jsonrpc2/client"
"sync/atomic"
)

func Default() *WorkerClient {
return &WorkerClient{BaseURL: "http://127.0.0.1:9999"}
}

type WorkerClient struct {
BaseURL string
sequence uint64
}

//
func (impl *WorkerClient) Kill(ctx context.Context) (reply bool, err error) {
err = client.CallHTTP(ctx, impl.BaseURL, "Worker.Kill", atomic.AddUint64(&impl.sequence, 1), &reply)
return
}

//
func (impl *WorkerClient) Peers(ctx context.Context) (reply []string, err error) {
err = client.CallHTTP(ctx, impl.BaseURL, "Worker.Peers", atomic.AddUint64(&impl.sequence, 1), &reply)
return
}
42 changes: 42 additions & 0 deletions cmd/tinc-desktop/internal/api/server.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions cmd/tinc-desktop/internal/interface.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package internal

import "context"

/*
We can't control launched tincd daemon after start.
After privilege escalation (*sudo, oascript, runas, ...) we have no more control to the process:
* impossible send signal (to rooted process)
* impossible control by STDIN/STDOUT due to privilege escalation apps are non-redirecting pipes
So we have to control by TCP, however we can detect death by exit
```
Desktop application
|
|
| worker for network (separate process due to privilege escalation)
+.......+
| |
| |
Peers +<----->|
| |
Kill +------>|
|
```
*/
type Worker interface {
Kill(ctx context.Context) (bool, error)
Peers(ctx context.Context) ([]string, error)
}

type Port interface {
API() Worker
Done() <-chan struct{}
Name() string
}

type Spawner interface {
Spawn(network string, done chan<- error) (Port, error)
}
Loading

0 comments on commit e2734c6

Please sign in to comment.