Skip to content

Commit

Permalink
Merge pull request #689 from aau-network-security/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
mrtrkmn authored Oct 16, 2021
2 parents d12ba33 + e854e79 commit 611203d
Show file tree
Hide file tree
Showing 13 changed files with 374 additions and 106 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/deploy-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
# Triggers the workflow on tagged commits
push:
tags:
- '*.*.*'
- '[0-9]+.[0-9]+.[0-9]+'

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
Expand Down Expand Up @@ -54,4 +54,4 @@ jobs:
ANSIBLE_CONFIG: ./ansible.cfg

- name: Clean Key
run: rm -rf ~/.privkey
run: rm -rf ~/.privkey
30 changes: 30 additions & 0 deletions .github/workflows/release-develop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Pre-Release for Haaukins

# Controls when the action will run.
on:
# Triggers the workflow on tagged commits
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+-pre'

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: -f .goreleaser.prerelease.yml --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


188 changes: 188 additions & 0 deletions .goreleaser.prerelease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
# .goreleaser.yml
before:
hooks:
- go mod tidy
builds:
# You can have multiple builds defined as a yaml list
- # ID of the build.
# Defaults to the project name.
id: "hkn"

# Path to main.go file or main package.
# Default is `.`.
main: ./client/main.go

# Binary name.
# Can be a path (e.g. `bin/app`) to wrap the binary in a directory.
# Default is the name of the project directory.
binary: hkn

# Custom flags templates.
# Default is empty.
flags:
- -tags=netgo

# Custom ldflags templates.
# Default is `-s -w -X main.version={{.Version}} -X main.commit={{.ShortCommit}} -X main.date={{.Date}} -X main.builtBy=goreleaser`.
ldflags:
- -s -w -X github.com/aau-network-security/haaukins/client/cli.Version={{ .Version }}

# Custom environment variables to be set during the builds.
# Default is empty.
env:
- CGO_ENABLED=0

# GOOS list to build for.
# For more info refer to: https://golang.org/doc/install/source#environment
# Defaults are darwin and linux.
goos:
- windows
- darwin
- linux

# GOARCH to build for.
# For more info refer to: https://golang.org/doc/install/source#environment
# Defaults are 386 and amd64.
goarch:
- amd64
- 386

- id: "hknd"
env:
- CGO_ENABLED=0
main: ./main.go
binary: hknd
flags:
- -tags=netgo
ldflags:
- -s -w -X github.com/aau-network-security/haaukins/daemon.Version={{ .Version }}
goos:
- linux
goarch:
- 386
- amd64

archives:
- # ID of this archive.
# Defaults to `default`.
id: haaukins

# Builds reference which build instances should be archived in this archive.
builds:
- hknd

# Archive name template.
# Defaults:
# - if format is `tar.gz`, `gz` or `zip`:
# - `{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}`
# - if format is `binary`:
# - `{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}`
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"


# Replacements for GOOS and GOARCH in the archive name.
# Keys should be valid GOOSs or GOARCHs.
# Values are the respective replacements.
# Default is empty.
replacements:
amd64: 64-bit


# Set to true, if you want all files in the archive to be in a single directory.
# If set to true and you extract the archive 'goreleaser_Linux_arm64.tar.gz',
# you get a folder 'goreleaser_Linux_arm64'.
# If set to false, all files are extracted separately.
# You can also set it to a custom folder name (templating is supported).
# Default is false.
wrap_in_directory: true

# Archive format. Valid options are `tar.gz`, `gz`, `zip` and `binary`.
# If format is `binary`, no archives are created and the binaries are instead
# uploaded directly.
# Default is `tar.gz`.
format: zip

# Additional files/globs you want to add to the archive.
# Defaults are any files matching `LICENCE*`, `LICENSE*`,
# `README*` and `CHANGELOG*` (case-insensitive).
files:
- LICENSE
- readme.md
- dist/CHANGELOG.md


- # ID of this archive.
id: haaukins_client

# Builds reference which build instances should be archived in this archive.
builds:
- hkn

# Archive name template.
# Defaults:
# - if format is `tar.gz`, `gz` or `zip`:
# - `{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}`
# - if format is `binary`:
# - `{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}`

name_template: "{{ .ProjectName }}_cli_{{ .Version }}_{{ .Os }}_{{ .Arch }}"


# Replacements for GOOS and GOARCH in the archive name.
# Keys should be valid GOOSs or GOARCHs.
# Values are the respective replacements.
# Default is empty.
replacements:
amd64: 64-bit
386: 32-bit
darwin: macOS

# Set to true, if you want all files in the archive to be in a single directory.
# If set to true and you extract the archive 'goreleaser_Linux_arm64.tar.gz',
# you get a folder 'goreleaser_Linux_arm64'.
# If set to false, all files are extracted separately.
# You can also set it to a custom folder name (templating is supported).
# Default is false.
wrap_in_directory: true

# Archive format. Valid options are `tar.gz`, `gz`, `zip` and `binary`.
# If format is `binary`, no archives are created and the binaries are instead
# uploaded directly.
# Default is `tar.gz`.
format: zip

# Additional files/globs you want to add to the archive.
# Defaults are any files matching `LICENCE*`, `LICENSE*`,
# `README*` and `CHANGELOG*` (case-insensitive).
files:
- LICENSE
- readme.md
- dist/CHANGELOG.md

checksum:
# You can change the name of the checksums file.
# Default is `{{ .ProjectName }}_{{ .Version }}_checksums.txt`.
name_template: "v_{{ .Version }}_{{ .ProjectName }}_checksums.txt"

# Algorithm to be used.
# Accepted options are sha256, sha512, sha1, crc32, md5, sha224 and sha384.
# Default is sha256.
algorithm: sha256

release:
prerelease: true
# it will be enabled later
# brews:
# -
# ids:
# - haaukins_client
# tap:
# owner: aau-network-security
# name: homebrew-haaukins
# folder: Formula
# homepage: https://github.com/aau-network-security/haaukins/
# description: Haaukins CLI
# install: |
# bin.install "hkn"
# test: |
# system "#{bin}/hkn --help"
14 changes: 8 additions & 6 deletions daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,24 +327,26 @@ func New(conf *Config) (*daemon, error) {
exClient: exServiceClient,
}

var vpnAddress string
for _, ef := range dbEvents {

var eventConfig store.EventConfig
// check through status of event
// suspended is also included since at first start
// daemon should be aware of the event which is suspended
// and configuration should be loaded to daemon
if ef.Status == Running || ef.Status == Suspended {
vpnIP, err := getVPNIP()
if err != nil {
log.Error().Msgf("Getting VPN address error on New() in daemon %v", err)
if ef.OnlyVPN == int32(VPN) || ef.OnlyVPN == int32(VPNBrowser) {
vpnIP, err := getVPNIP()
if err != nil {
log.Error().Msgf("Getting VPN address error on New() in daemon %v", err)
}
vpnAddress = fmt.Sprintf("%s.240.1/22", vpnIP)
}
vpnAddress := fmt.Sprintf("%s.240.1/22", vpnIP)

if ef.Status == Suspended {
d.dbClient.SetEventStatus(ctx, &pbc.SetEventStatusRequest{Status: Running, EventTag: ef.Tag})
ef.Status = Running
}

eventConfig = d.generateEventConfig(ef, ef.Status, vpnAddress)
err = d.createEventFromEventDB(context.Background(), eventConfig)
if err != nil {
Expand Down
Loading

0 comments on commit 611203d

Please sign in to comment.