Skip to content

Commit

Permalink
CLI fixes and enhancements (#374)
Browse files Browse the repository at this point in the history
* interface cleanup bug, logging

* cli client enrollment, logging

* more logs, error handling

* debs, rpms, services

* fix time

* comment out actions

* cleanup

* fix build

* fix arch

* fix dependency check, put binaries in sbin

* add logging options to subcommands

* better error message

* set perms

* make perms non windows

* modify error handling

* version and protobufs bump, cleanup
  • Loading branch information
t-aleksander authored Jan 17, 2025
1 parent 660e6be commit 4705e0d
Show file tree
Hide file tree
Showing 11 changed files with 351 additions and 110 deletions.
5 changes: 5 additions & 0 deletions .fpm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-s dir
--name dg
--description "defguard CLI client"
--url "https://defguard.net/"
--maintainer "teonite"
28 changes: 28 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,34 @@ jobs:
asset_path: dg-linux-${{ matrix.binary_arch }}-${{ github.ref_name }}.tar.gz
asset_name: dg-linux-${{ matrix.binary_arch }}-${{ github.ref_name }}.tar.gz
asset_content_type: application/octet-stream
- name: Build dg deb
uses: defGuard/fpm-action@main
with:
fpm_args: 'dg-linux-${{ matrix.binary_arch }}-${{ github.ref_name }}=/usr/sbin/dg dg.service=/usr/lib/systemd/system/dg.service src-tauri/cli/.env=/etc/defguard/dg.conf'
fpm_opts: '--architecture ${{ matrix.binary_arch }} --debug --output-type deb --version ${{ env.VERSION }} --package dg-linux-${{ matrix.binary_arch }}-${{ github.ref_name }}.deb'
- name: Upload DEB
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: dg-linux-${{ matrix.binary_arch }}-${{ github.ref_name }}.deb
asset_name: dg-linux-${{ matrix.binary_arch }}-${{ github.ref_name }}.deb
asset_content_type: application/octet-stream
- name: Build dg rpm
uses: defGuard/fpm-action@main
with:
fpm_args: 'dg-linux-${{ matrix.binary_arch }}-${{ github.ref_name }}=/usr/sbin/dg dg.service=/usr/lib/systemd/system/dg.service src-tauri/cli/.env=/etc/defguard/dg.conf'
fpm_opts: '--architecture ${{ matrix.binary_arch }} --debug --output-type rpm --version ${{ env.VERSION }} --package dg-linux-${{ matrix.binary_arch }}-${{ github.ref_name }}.rpm'
- name: Upload RPM
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: dg-linux-${{ matrix.binary_arch }}-${{ github.ref_name }}.rpm
asset_name: dg-linux-${{ matrix.binary_arch }}-${{ github.ref_name }}.rpm
asset_content_type: application/octet-stream

build-macos:
needs:
Expand Down
21 changes: 21 additions & 0 deletions dg.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[Unit]
Description=Defguard CLI client
Documentation=https://docs.defguard.net/
Wants=network-online.target
After=network-online.target

[Service]
ExecReload=/bin/kill -HUP $MAINPID
EnvironmentFile=/etc/defguard/dg.conf
ExecStart=/usr/sbin/dg
KillMode=process
KillSignal=SIGINT
LimitNOFILE=65536
LimitNPROC=infinity
Restart=on-failure
RestartSec=2
TasksMax=infinity
OOMScoreAdjust=-1000

[Install]
WantedBy=multi-user.target
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "defguard-client",
"private": false,
"version": "1.1.1",
"version": "1.1.2",
"type": "module",
"scripts": {
"dev": "npm-run-all --parallel vite typesafe-i18n",
Expand Down
6 changes: 4 additions & 2 deletions src-tauri/Cargo.lock

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

4 changes: 2 additions & 2 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ edition = "2021"
homepage = "https://github.com/DefGuard/client"
license-file = "../LICENSE.md"
rust-version = "1.80"
version = "1.1.1"
version = "1.1.2"

[package]
name = "defguard-client"
Expand All @@ -38,7 +38,7 @@ clap = { version = "4.5", features = ["cargo", "derive", "env"] }
chrono = { version = "0.4", features = ["serde"] }
common = { path = "common" }
dark-light = "2.0"
defguard_wireguard_rs = { workspace = true }
defguard_wireguard_rs = { workspace = true, features = ["check_dependencies"] }
dirs-next = "2.0"
lazy_static = "1.5"
log = { version = "0.4", features = ["serde"] }
Expand Down
3 changes: 3 additions & 0 deletions src-tauri/cli/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# DG_VERBOSE=true
# DG_DEBUG=true
# DG_CONFIG=/path/to/your/config.json
6 changes: 4 additions & 2 deletions src-tauri/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,18 @@ version.workspace = true
prost-build = "0.13"

[dependencies]
clap = { version = "4.5", features = ["cargo", "derive"] }
clap = { version = "4.5", features = ["cargo", "derive", "env"] }
common = { path = "../common" }
defguard_wireguard_rs = { workspace = true }
defguard_wireguard_rs = { workspace = true, features = ["check_dependencies"] }
dirs-next = "2.0"
prost = "0.13"
reqwest = { version = "0.12", features = ["cookies", "json"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
thiserror = "2.0"
tokio = { version = "1", features = ["macros", "rt-multi-thread", "signal"] }
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter", "json"] }

# Dummy feature to let tauri build the release.
[features]
Expand Down
Loading

0 comments on commit 4705e0d

Please sign in to comment.