Skip to content

Commit

Permalink
Added the ability to configure endpoints availability (Platform Confi…
Browse files Browse the repository at this point in the history
…gs and Swagger)
  • Loading branch information
hopleus committed Oct 5, 2024
1 parent 9b21de0 commit 11b6693
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 53 deletions.
88 changes: 44 additions & 44 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,28 +110,28 @@ kos:
- '{{ trimprefix .Tag "v" }}'
- "sha-{{ .ShortCommit }}"

- id: dockerhub
build: headscale
base_image: gcr.io/distroless/base-debian12
repository: hopleus/headscale
bare: true
platforms:
- linux/amd64
- linux/386
- linux/arm64
- linux/arm/v7
tags:
- "{{ if not .Prerelease }}latest{{ end }}"
- "{{ if not .Prerelease }}{{ .Major }}.{{ .Minor }}.{{ .Patch }}{{ end }}"
- "{{ if not .Prerelease }}{{ .Major }}.{{ .Minor }}{{ end }}"
- "{{ if not .Prerelease }}{{ .Major }}{{ end }}"
- "{{ if not .Prerelease }}v{{ .Major }}.{{ .Minor }}.{{ .Patch }}{{ end }}"
- "{{ if not .Prerelease }}v{{ .Major }}.{{ .Minor }}{{ end }}"
- "{{ if not .Prerelease }}v{{ .Major }}{{ end }}"
- "{{ if not .Prerelease }}stable{{ else }}unstable{{ end }}"
- "{{ .Tag }}"
- '{{ trimprefix .Tag "v" }}'
- "sha-{{ .ShortCommit }}"
# - id: dockerhub
# build: headscale
# base_image: gcr.io/distroless/base-debian12
# repository: hopleus/headscale
# bare: true
# platforms:
# - linux/amd64
# - linux/386
# - linux/arm64
# - linux/arm/v7
# tags:
# - "{{ if not .Prerelease }}latest{{ end }}"
# - "{{ if not .Prerelease }}{{ .Major }}.{{ .Minor }}.{{ .Patch }}{{ end }}"
# - "{{ if not .Prerelease }}{{ .Major }}.{{ .Minor }}{{ end }}"
# - "{{ if not .Prerelease }}{{ .Major }}{{ end }}"
# - "{{ if not .Prerelease }}v{{ .Major }}.{{ .Minor }}.{{ .Patch }}{{ end }}"
# - "{{ if not .Prerelease }}v{{ .Major }}.{{ .Minor }}{{ end }}"
# - "{{ if not .Prerelease }}v{{ .Major }}{{ end }}"
# - "{{ if not .Prerelease }}stable{{ else }}unstable{{ end }}"
# - "{{ .Tag }}"
# - '{{ trimprefix .Tag "v" }}'
# - "sha-{{ .ShortCommit }}"

- id: ghcr-debug
repository: ghcr.io/hopleus/headscale
Expand Down Expand Up @@ -159,28 +159,28 @@ kos:
- '{{ trimprefix .Tag "v" }}-debug'
- "sha-{{ .ShortCommit }}-debug"

- id: dockerhub-debug
build: headscale
base_image: gcr.io/distroless/base-debian12:debug
repository: hopleus/headscale
bare: true
platforms:
- linux/amd64
- linux/386
- linux/arm64
- linux/arm/v7
tags:
- "{{ if not .Prerelease }}latest-debug{{ end }}"
- "{{ if not .Prerelease }}{{ .Major }}.{{ .Minor }}.{{ .Patch }}-debug{{ end }}"
- "{{ if not .Prerelease }}{{ .Major }}.{{ .Minor }}-debug{{ end }}"
- "{{ if not .Prerelease }}{{ .Major }}-debug{{ end }}"
- "{{ if not .Prerelease }}v{{ .Major }}.{{ .Minor }}.{{ .Patch }}-debug{{ end }}"
- "{{ if not .Prerelease }}v{{ .Major }}.{{ .Minor }}-debug{{ end }}"
- "{{ if not .Prerelease }}v{{ .Major }}-debug{{ end }}"
- "{{ if not .Prerelease }}stable{{ else }}unstable-debug{{ end }}"
- "{{ .Tag }}-debug"
- '{{ trimprefix .Tag "v" }}-debug'
- "sha-{{ .ShortCommit }}-debug"
# - id: dockerhub-debug
# build: headscale
# base_image: gcr.io/distroless/base-debian12:debug
# repository: hopleus/headscale
# bare: true
# platforms:
# - linux/amd64
# - linux/386
# - linux/arm64
# - linux/arm/v7
# tags:
# - "{{ if not .Prerelease }}latest-debug{{ end }}"
# - "{{ if not .Prerelease }}{{ .Major }}.{{ .Minor }}.{{ .Patch }}-debug{{ end }}"
# - "{{ if not .Prerelease }}{{ .Major }}.{{ .Minor }}-debug{{ end }}"
# - "{{ if not .Prerelease }}{{ .Major }}-debug{{ end }}"
# - "{{ if not .Prerelease }}v{{ .Major }}.{{ .Minor }}.{{ .Patch }}-debug{{ end }}"
# - "{{ if not .Prerelease }}v{{ .Major }}.{{ .Minor }}-debug{{ end }}"
# - "{{ if not .Prerelease }}v{{ .Major }}-debug{{ end }}"
# - "{{ if not .Prerelease }}stable{{ else }}unstable-debug{{ end }}"
# - "{{ .Tag }}-debug"
# - '{{ trimprefix .Tag "v" }}-debug'
# - "sha-{{ .ShortCommit }}-debug"

checksum:
name_template: "checksums.txt"
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
- Improved compatibilty of built-in DERP server with clients connecting over WebSocket.
- Allow nodes to use SSH agent forwarding [#2145](https://github.com/juanfont/headscale/pull/2145)

## [FORK] 0.23.0-1 (2024-10-04)
### Changes

- Add HostInfo to Node response
- Added the ability to configure endpoints availability (Platform Configs and Swagger)

## 0.23.0 (2024-09-18)

Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Differences from the original HeadScale assembly

- [x] Add HostInfo to Node response
- [x] Added the ability to configure endpoints availability (Platform Configs and Swagger)

# HeadScale

![headscale logo](./docs/logo/headscale3_header_stacked_left.png)

![ci](https://github.com/juanfont/headscale/actions/workflows/test.yml/badge.svg)
Expand Down
7 changes: 7 additions & 0 deletions config-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -384,3 +384,10 @@ logtail:
# default static port 41641. This option is intended as a workaround for some buggy
# firewall devices. See https://tailscale.com/kb/1181/firewalls/ for more information.
randomize_client_port: false

# Configuration routes
routes:
# Disabling routes to download configuration for windows and apple
platformConfig: false
# Disabling routes for Swagger
swagger: false
23 changes: 14 additions & 9 deletions hscontrol/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,15 +447,20 @@ func (h *Headscale) createRouter(grpcMux *grpcRuntime.ServeMux) *mux.Router {
if provider, ok := h.authProvider.(*AuthProviderOIDC); ok {
router.HandleFunc("/oidc/callback", provider.OIDCCallbackHandler).Methods(http.MethodGet)
}
router.HandleFunc("/apple", h.AppleConfigMessage).Methods(http.MethodGet)
router.HandleFunc("/apple/{platform}", h.ApplePlatformConfig).
Methods(http.MethodGet)
router.HandleFunc("/windows", h.WindowsConfigMessage).Methods(http.MethodGet)

// TODO(kristoffer): move swagger into a package
router.HandleFunc("/swagger", headscale.SwaggerUI).Methods(http.MethodGet)
router.HandleFunc("/swagger/v1/openapiv2.json", headscale.SwaggerAPIv1).
Methods(http.MethodGet)

if h.cfg.Routes.PlatformConfig {
router.HandleFunc("/apple", h.AppleConfigMessage).Methods(http.MethodGet)
router.HandleFunc("/apple/{platform}", h.ApplePlatformConfig).
Methods(http.MethodGet)
router.HandleFunc("/windows", h.WindowsConfigMessage).Methods(http.MethodGet)
}

if h.cfg.Routes.Swagger {
// TODO(kristoffer): move swagger into a package
router.HandleFunc("/swagger", headscale.SwaggerUI).Methods(http.MethodGet)
router.HandleFunc("/swagger/v1/openapiv2.json", headscale.SwaggerAPIv1).
Methods(http.MethodGet)
}

if h.cfg.DERP.ServerEnabled {
router.HandleFunc("/derp", h.DERPServer.DERPHandler)
Expand Down
15 changes: 15 additions & 0 deletions hscontrol/types/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ type Config struct {
Policy PolicyConfig

Tuning Tuning

Routes RoutesConfig
}

type DNSConfig struct {
Expand Down Expand Up @@ -203,6 +205,11 @@ type LogConfig struct {
Level zerolog.Level
}

type RoutesConfig struct {
PlatformConfig bool
Swagger bool
}

type Tuning struct {
NotifierSendTimeout time.Duration
BatchChangeDelay time.Duration
Expand Down Expand Up @@ -284,6 +291,9 @@ func LoadConfig(path string, isFile bool) error {
viper.SetDefault("tuning.batch_change_delay", "800ms")
viper.SetDefault("tuning.node_mapsession_buffered_chan_size", 30)

viper.SetDefault("routes.platformConfig", true)
viper.SetDefault("routes.swagger", true)

viper.SetDefault("prefixes.allocation", string(IPAllocationStrategySequential))

if err := viper.ReadInConfig(); err != nil {
Expand Down Expand Up @@ -920,6 +930,11 @@ func LoadServerConfig() (*Config, error) {
"tuning.node_mapsession_buffered_chan_size",
),
},

Routes: RoutesConfig{
PlatformConfig: viper.GetBool("routes.platformConfig"),
Swagger: viper.GetBool("routes.swagger"),
},
}, nil
}

Expand Down

0 comments on commit 11b6693

Please sign in to comment.