@ -19,6 +19,7 @@ import (
"expvar"
"expvar"
"flag"
"flag"
"fmt"
"fmt"
"html/template"
"io"
"io"
"log"
"log"
"math"
"math"
@ -212,25 +213,16 @@ func main() {
tsweb . AddBrowserHeaders ( w )
tsweb . AddBrowserHeaders ( w )
w . Header ( ) . Set ( "Content-Type" , "text/html; charset=utf-8" )
w . Header ( ) . Set ( "Content-Type" , "text/html; charset=utf-8" )
w . WriteHeader ( 200 )
w . WriteHeader ( 200 )
io . WriteString ( w , ` < html > < body >
err := homePageTemplate . Execute ( w , templateData {
< h1 > DERP < / h1 >
ShowAbuseInfo : validProdHostname . MatchString ( * hostname ) ,
< p >
Disabled : ! * runDERP ,
This is a < a href = "https://tailscale.com/" > Tailscale < / a > DERP server .
AllowDebug : tsweb . AllowDebugAccess ( r ) ,
< / p >
} )
< p >
if err != nil {
Documentation :
if r . Context ( ) . Err ( ) == nil {
< / p >
log . Printf ( "homePageTemplate.Execute: %v" , err )
< ul >
< li > < a href = "https://tailscale.com/kb/1232/derp-servers" > About DERP < / a > < / li >
< li > < a href = "https://pkg.go.dev/tailscale.com/derp" > Protocol & Go docs < / a > < / li >
< li > < a href = "https://github.com/tailscale/tailscale/tree/main/cmd/derper#derp" > How to run a DERP server < / a > < / li >
< / ul >
` )
if ! * runDERP {
io . WriteString ( w , ` <p>Status: <b>disabled</b></p> ` )
}
}
if tsweb . AllowDebugAccess ( r ) {
return
io . WriteString ( w , "<p>Debug info at <a href='/debug/'>/debug/</a>.</p>\n" )
}
}
} ) )
} ) )
mux . Handle ( "/robots.txt" , http . HandlerFunc ( func ( w http . ResponseWriter , r * http . Request ) {
mux . Handle ( "/robots.txt" , http . HandlerFunc ( func ( w http . ResponseWriter , r * http . Request ) {
@ -468,3 +460,52 @@ func init() {
return 0
return 0
} ) )
} ) )
}
}
type templateData struct {
ShowAbuseInfo bool
Disabled bool
AllowDebug bool
}
// homePageTemplate renders the home page using [templateData].
var homePageTemplate = template . Must ( template . New ( "home" ) . Parse ( ` < html > < body >
< h1 > DERP < / h1 >
< p >
This is a < a href = "https://tailscale.com/" > Tailscale < / a > DERP server .
< / p >
< p >
It provides STUN , interactive connectivity establishment , and relaying of end - to - end encrypted traffic
for Tailscale clients .
< / p >
{ { if . ShowAbuseInfo } }
< p >
If you suspect abuse , please contact < a href = "mailto:security@tailscale.com" > security @ tailscale . com < / a > .
< / p >
{ { end } }
< p >
Documentation :
< / p >
< ul >
{ { if . ShowAbuseInfo } }
< li > < a href = "https://tailscale.com/security-policies" > Tailscale Security Policies < / a > < / li >
< li > < a href = "https://tailscale.com/tailscale-aup" > Tailscale Acceptable Use Policies < / a > < / li >
{ { end } }
< li > < a href = "https://tailscale.com/kb/1232/derp-servers" > About DERP < / a > < / li >
< li > < a href = "https://pkg.go.dev/tailscale.com/derp" > Protocol & Go docs < / a > < / li >
< li > < a href = "https://github.com/tailscale/tailscale/tree/main/cmd/derper#derp" > How to run a DERP server < / a > < / li >
< / ul >
{ { if . Disabled } }
< p > Status : < b > disabled < / b > < / p >
{ { end } }
{ { if . AllowDebug } }
< p > Debug info at < a href = ' / debug / ' > / debug / < / a > . < / p >
{ { end } }
< / body >
< / html >
` ) )