Skip to content

Commit 23316cd

Browse files
committed
cmd/tclipd: disable HTTPS and warn if enabled but unavailable
If disable-https is not set but HTTPS support is unconfigured or broken, warn the user and fall through to HTTP-only.
1 parent e022fc3 commit 23316cd

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ environment variables. All of them are optional.
5353
| `-hide-funnel-users` | `HIDE_FUNNEL_USERS` | `false` | If set, don't display the username and profile picture of the user who created the paste in funneled pastes. |
5454
| `-http-port` | `HTTP_PORT` | unset | If set, expose individual pastes on a HTTP server running on the given port. |
5555
| `-control-url` | `TSNET_CONTROL_URL` | unset | If set, a custom control server to use, e.g. for Headscale users. |
56-
| `-disable-https` | `DISABLE_HTTPS` | `false` | If set, disable serving on HTTPS with Serve. Useful for Headscale deployments. |
56+
| `-disable-https` | `DISABLE_HTTPS` | `false`, becomes `true` when HTTPS is unavailable on the tailnet. | If set, disable serving on HTTPS, even if HTTPS serving is available. |
5757
| `-enable-line-numbers` | `ENABLE_LINE_NUMBERS` | `false` | If set, enable line numbers being shown when viewing a paste. |
5858
| `-enable-word-wrap` | `ENABLE_WORD_WRAP` | `false` | If set, allows lines to break and wrap to the following line. |
5959

cmd/tclipd/main.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -737,12 +737,14 @@ func main() {
737737
ctx := context.Background()
738738
tclipURL, ok := lc.ExpandSNIName(ctx, *hostname)
739739
if !ok {
740+
log.Println(tclipURL)
741+
log.Println("warning: HTTPS is unavailable, please check that it is enabled in the admin panel and that the hostname is configured correctly. Proceeding with only HTTP.")
742+
*disableHTTPS = true
743+
}
744+
745+
// if the user disabled HTTPS or HTTPS is unavailable
740746
if *disableHTTPS {
741747
tclipURL = *hostname
742-
} else {
743-
log.Println(tclipURL)
744-
log.Fatal("HTTPS is not enabled in the admin panel")
745-
}
746748
}
747749

748750
ln, err := s.Listen("tcp", ":80")

0 commit comments

Comments
 (0)