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

Add cloudflared #5333

Merged
merged 2 commits into from
Jul 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions cross/cloudflared/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
PKG_NAME = cloudflared
PKG_VERS = 2022.6.3
PKG_EXT = tar.gz
PKG_DIST_NAME = $(PKG_VERS).$(PKG_EXT)
PKG_DIST_SITE = https://github.com/cloudflare/cloudflared/archive
PKG_DIST_FILE = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT)
PKG_DIR = $(PKG_NAME)-$(PKG_VERS)

BUILD_DEPENDS = native/go

HOMEPAGE = https://github.com/cloudflare/cloudflared
COMMENT = Cloudflare Tunnel client (formerly Argo Tunnel)
LICENSE = Apache-2.0

GO_SRC_DIR = $(WORK_DIR)/$(PKG_NAME)-$(PKG_VERS)
GO_BIN_DIR = $(GO_SRC_DIR)/$(PKG_NAME)
COMPILE_TARGET = cloudflared_compile

include ../../mk/spksrc.cross-go.mk

.PHONY: cloudflared_compile
cloudflared_compile:
@$(RUN) $(MAKE) VERSION=$(PKG_VERS) LINK_FLAGS="-s -w" cloudflared
1 change: 1 addition & 0 deletions cross/cloudflared/PLIST
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bin:bin/cloudflared
3 changes: 3 additions & 0 deletions cross/cloudflared/digests
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cloudflared-2022.6.3.tar.gz SHA1 9bd0a13a8f873edb507d3ffafaa1600facdce73a
cloudflared-2022.6.3.tar.gz SHA256 74fb20e78f69db086f6044eae9d7a09bb3b59001a14d17c18edd9cb4ee8db4f6
cloudflared-2022.6.3.tar.gz MD5 458f453543f4c400ed16598666866471
23 changes: 23 additions & 0 deletions spk/cloudflared/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
SPK_NAME = cloudflared
SPK_VERS = 2022.6.3
SPK_REV = 1
SPK_ICON = src/cloudflared.png
DSM_UI_DIR = app

DEPENDS = cross/$(SPK_NAME)
UNSUPPORTED_ARCHS = $(PPC_ARCHS)

MAINTAINER = karasevm
DISPLAY_NAME = cloudflared
DESCRIPTION = Cloudflare Tunnel client (formerly Argo Tunnel).
HOMEPAGE = https://github.com/cloudflare/cloudflared
LICENSE = Apache-2.0
CHANGELOG = "Initial package release."

WIZARDS_DIR = src/wizard/

STARTABLE = yes
SERVICE_USER = auto
SERVICE_SETUP = src/service-setup.sh

include ../../mk/spksrc.spk.mk
Binary file added spk/cloudflared/src/cloudflared.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions spk/cloudflared/src/service-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
TOKEN_FILE="${SYNOPKG_PKGVAR}/token"
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Or does the token allow you to manage it remotely?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct, config file is used in locally managed tunnels and the token is used in tunnels managed through the dashboard. As far as I understand, remote management is the recommended set up. The service command is the same that's used in the systemd service created by following the official documentation.

It seems there are also ways to use a credentials file with remote management, but they involve an interactive setup, passing premade configs, or using the API (related issues cloudflare/cloudflared#645, cloudflare/cloudflared#665).


# Read token from file
if [ -e $TOKEN_FILE ]; then
CLOUDFLARED_TOKEN="$(cat $TOKEN_FILE)"
fi

SERVICE_COMMAND="${SYNOPKG_PKGDEST}/bin/cloudflared --no-autoupdate tunnel run --token ${CLOUDFLARED_TOKEN}"
SVC_BACKGROUND=y
SVC_WRITE_PID=y

service_postinst ()
{
# Save token to file
if [ -n "${wizard_cloudflared_token}" ]; then
echo "${wizard_cloudflared_token}" >> ${TOKEN_FILE}
fi
}
20 changes: 20 additions & 0 deletions spk/cloudflared/src/wizard/install_uifile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[
{
"step_title": "Tunnel configuration",
"items": [
{
"type": "textfield",
"desc": "Token for the cloudflare tunnel",
"subitems": [
{
"key": "wizard_cloudflared_token",
"desc": "Tunnel token",
"validator": {
"allowBlank": false
}
}
]
}
]
}
]