Skip to content

Commit 87d39e8

Browse files
authored
Merge pull request #64 from iFargle/inpage-search
v0.6.0
2 parents a098843 + 7cef7f4 commit 87d39e8

30 files changed

+1027
-391
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ ENV TZ="UTC"
4343
ENV COLOR="blue-grey"
4444
ENV HS_SERVER=http://localhost/
4545
ENV KEY=""
46-
ENV SCRIPT_NAME=/
46+
# ENV SCRIPT_NAME=/
4747
ENV DOMAIN_NAME=http://localhost
4848
ENV AUTH_TYPE=""
4949
ENV LOG_LEVEL="Info"

Jenkinsfile

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ pipeline {
33
label 'linux-x64'
44
}
55
environment {
6-
APP_VERSION = 'v0.5.6'
7-
HS_VERSION = "v0.20.0" // Version of Headscale this is compatible with
6+
APP_VERSION = 'v0.6.0'
7+
HS_VERSION = "v0.21.0" // Version of Headscale this is compatible with
88
BUILD_DATE = ''
9-
BUILDER_NAME = "multiarch-${env.BRANCH_NAME}"
9+
BUILDER_NAME = "multiarch-${env.BUILD_TAG}"
10+
1011

1112
DOCKERHUB_CRED = credentials('dockerhub-ifargle-pat')
1213

@@ -21,14 +22,11 @@ pipeline {
2122
timestamps()
2223
}
2324
stages {
24-
stage ('Jenkins ENV') {
25+
stage('Build ENV') {
2526
steps {
27+
2628
sh 'printenv'
2729
script { BUILD_DATE = java.time.LocalDate.now() }
28-
}
29-
}
30-
stage('Create Build ENV') {
31-
steps {
3230
sh """
3331
# Create the builder:
3432
docker buildx create --name $BUILDER_NAME --driver-opt=image=moby/buildkit
@@ -85,6 +83,30 @@ pipeline {
8583
}
8684
}
8785
}
86+
stage('Pull Test') {
87+
steps {
88+
script {
89+
if (env.BRANCH_NAME == 'main') {
90+
sh """
91+
docker pull git.sysctl.io/albert/headscale-webui:latest
92+
docker pull registry-1.docker.io/ifargle/headscale-webui:latest
93+
docker pull ghcr.io/ifargle/headscale-webui:latest
94+
docker pull git.sysctl.io/albert/headscale-webui:${APP_VERSION}
95+
docker pull registry-1.docker.io/ifargle/headscale-webui:${APP_VERSION}
96+
docker pull ghcr.io/ifargle/headscale-webui:${APP_VERSION}
97+
"""
98+
}
99+
else {
100+
sh """
101+
docker pull git.sysctl.io/albert/headscale-webui:testing
102+
docker pull ghcr.io/ifargle/headscale-webui:testing
103+
docker pull git.sysctl.io/albert/headscale-webui:${env.BRANCH_NAME}
104+
docker pull ghcr.io/ifargle/headscale-webui:${env.BRANCH_NAME}
105+
"""
106+
}
107+
}
108+
}
109+
}
88110
}
89111
post {
90112
always {

README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
---
1717
# Features
1818
1. Enable/Disable routes and exit nodes
19+
* Manage failover routes as well
1920
2. Add, move, rename, and remove machines
2021
3. Add and remove users/namespaces
2122
4. Add and expire PreAuth keys
@@ -32,8 +33,13 @@
3233
* Enable / disable routes and exit nodes
3334
* Add and delete machine tags
3435
7. Basic and OIDC Authentication
35-
* OIDC Authentication tested with Authelia
36+
* OIDC Authentication tested with Authelia and Keycloak
3637
8. Change your color theme! See MaterializeCSS Documentation for Colors for examples.
38+
9. Search your machines and users.
39+
* Machines have tags you can use to filter search:
40+
* `tag:tagname` Searches only for specific tags
41+
* `machine:machine-name` Searches only for specific machines
42+
* `user:user-name` Searches only for specific users
3743

3844

3945
---
@@ -42,16 +48,11 @@
4248

4349
---
4450
# Screenshots:
45-
Overview Page:
46-
![Overview](screenshots/oidc_overview.png)
47-
Users Page:
51+
![Overview](screenshots/overview.png)
52+
![Routes](screenshots/routes.png)
53+
![Machines](screenshots/machines.png)
4854
![Users](screenshots/users.png)
49-
Machine Information:
50-
![Add a new machine](screenshots/machines_expanded.png)
51-
Machines Page:
52-
![Machine Details](screenshots/machines.png)
53-
Settings Page showing an API Key Test:
54-
![API Key Test](screenshots/settings.png)
55+
![Settings](screenshots/settings.png)
5556

5657
---
5758
# Tech used:

SETUP.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
*PR's to help expand and improve documentation are always welcome!*
2-
* Thanks to @FredericIV for assistance with Keycloak and Caddy
3-
* Thanks to @qiangyt for assistance with general reverse proxy fixes and nginx
42

53
# Installation and Setup
64
* Use [docker-compose.yml](docker-compose.yml) as an example
@@ -17,7 +15,7 @@
1715
* `TZ` - Set this to your current timezone. Example: `Asia/Tokyo`
1816
* `COLOR` Set this to your preferred color scheme. See the [MaterializeCSS docs](https://materializecss.github.io/materialize/color.html#palette) for examples. Only set the "base" color -- ie, instead of `blue-gray darken-1`, just use `blue-gray`.
1917
* `HS_SERVER` is the URL for your Headscale control server.
20-
* `SCRIPT_NAME` is your "Base Path" for hosting. For example, if you want to host on http://localhost/admin, set this to `/admin`
18+
* `SCRIPT_NAME` is your "Base Path" for hosting. For example, if you want to host on http://localhost/admin, set this to `/admin`, otherwise remove this variable entirely.
2119
* `KEY` is your encryption key. Set this to a random value generated from `openssl rand -base64 32`
2220
* `AUTH_TYPE` can be set to `Basic` or `OIDC`. See the [Authentication](#Authentication) section below for more information.
2321
* `LOG_LEVEL` can be one of `Debug`, `Info`, `Warning`, `Error`, or `Critical` for decreasing verbosity. Default is `Info` if removed from your Environment.

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ services:
88
- COLOR=red # Use the base colors (ie, no darken-3, etc) -
99
- HS_SERVER=https://headscale.$DOMAIN # Reachable endpoint for your Headscale server
1010
- DOMAIN_NAME=https://headscale.$DOMAIN # The base domain name for this container.
11-
- SCRIPT_NAME=/admin # This is your applications base path (wsgi requires the name "SCRIPT_NAME")
11+
- SCRIPT_NAME=/admin # This is your applications base path (wsgi requires the name "SCRIPT_NAME"). Remove if you are hosing at the root /
1212
- KEY="YourKeyBetweenQuotes" # Generate with "openssl rand -base64 32" - used to encrypt your key on disk.
1313
- AUTH_TYPE=oidc # AUTH_TYPE is either Basic or OIDC. Empty for no authentication
1414
- LOG_LEVEL=info # Log level. "DEBUG", "ERROR", "WARNING", or "INFO". Default "INFO"

headscale.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# pylint: disable=wrong-import-order
22

3-
import requests, json, os, logging
3+
import requests, json, os, logging, yaml
44
from cryptography.fernet import Fernet
55
from datetime import timedelta, date
66
from dateutil import parser
@@ -19,8 +19,21 @@
1919
##################################################################
2020
# Functions related to HEADSCALE and API KEYS
2121
##################################################################
22-
23-
def get_url(): return os.environ['HS_SERVER']
22+
def get_url(inpage=False):
23+
if not inpage:
24+
return os.environ['HS_SERVER']
25+
config_file = ""
26+
try:
27+
config_file = open("/etc/headscale/config.yml", "r")
28+
app.logger.info("Opening /etc/headscale/config.yml")
29+
except:
30+
config_file = open("/etc/headscale/config.yaml", "r")
31+
app.logger.info("Opening /etc/headscale/config.yaml")
32+
config_yaml = yaml.safe_load(config_file)
33+
if "server_url" in config_yaml:
34+
return str(config_yaml["server_url"])
35+
app.logge.warning("Failed to find server_url in the config. Falling back to ENV variable")
36+
return os.environ['HS_SERVER']
2437

2538
def set_api_key(api_key):
2639
# User-set encryption key
@@ -194,9 +207,8 @@ def move_user(url, api_key, machine_id, new_user):
194207
return response.json()
195208

196209
def update_route(url, api_key, route_id, current_state):
197-
action = ""
198-
if current_state == "True": action = "disable"
199-
if current_state == "False": action = "enable"
210+
action = "disable" if current_state == "True" else "enable"
211+
200212
app.logger.info("Updating Route %s: Action: %s", str(route_id), str(action))
201213

202214
# Debug
@@ -299,9 +311,8 @@ def get_routes(url, api_key):
299311
}
300312
)
301313
return response.json()
302-
303314
##################################################################
304-
# Functions related to NAMESPACES
315+
# Functions related to USERS
305316
##################################################################
306317

307318
# Get all users in use
@@ -370,7 +381,7 @@ def add_user(url, api_key, data):
370381
return {"status": status, "body": response.json()}
371382

372383
##################################################################
373-
# Functions related to PREAUTH KEYS in NAMESPACES
384+
# Functions related to PREAUTH KEYS in USERS
374385
##################################################################
375386

376387
# Get all PreAuth keys associated with a user "user_name"

helper.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,21 @@ def key_check():
7373
def get_color(import_id, item_type = ""):
7474
""" Sets colors for users/namespaces """
7575
# Define the colors... Seems like a good number to start with
76+
if item_type == "failover":
77+
colors = [
78+
"teal lighten-1",
79+
"blue lighten-1",
80+
"blue-grey lighten-1",
81+
"indigo lighten-2",
82+
"brown lighten-1",
83+
"grey lighten-1",
84+
"indigo lighten-2",
85+
"deep-orange lighten-1",
86+
"yellow lighten-2",
87+
"purple lighten-2",
88+
]
89+
index = import_id % len(colors)
90+
return colors[index]
7691
if item_type == "text":
7792
colors = [
7893
"red-text text-lighten-1",

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "headscale-webui"
3-
version = "v0.5.6"
3+
version = "v0.6.0"
44
description = "A simple web UI for small-scale Headscale deployments."
55
authors = ["Albert Copeland <albert@sysctl.io>"]
66
license = "AGPL"

0 commit comments

Comments
 (0)