Skip to content

Commit

Permalink
Added derpmesh to development environment
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Kosiewski <[email protected]>
  • Loading branch information
ThomasK33 committed Oct 24, 2023
1 parent d9d739b commit 8965a3e
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 17 deletions.
15 changes: 14 additions & 1 deletion Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,22 @@ alias align := check-structalign
_default:
@just --list

dev:
dev: mkcerts
go install tailscale.com/cmd/derper@main
zellij -s tunnel --layout tunnel_layout.kdl

mesh: mkcerts
go install tailscale.com/cmd/derper@main
zellij -s derpmesh --layout derp_mesh.kdl

# --- Certificates ---

mkcerts:
mkdir -p tmp/certs
mkcert -cert-file tmp/certs/derp-a.crt -key-file tmp/certs/derp-a.key derp-a.local derp-a
mkcert -cert-file tmp/certs/derp-b.crt -key-file tmp/certs/derp-b.key derp-b.local derp-b
mkcert -cert-file tmp/certs/derp-c.crt -key-file tmp/certs/derp-c.key derp-c.local derp-c

# --- Code quality ---

# Run golangci-lint for all packages
Expand Down
29 changes: 29 additions & 0 deletions derp_mesh.kdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
layout {
default_tab_template {
// the default zellij tab-bar and status bar plugins
pane size=1 borderless=true {
plugin location="zellij:tab-bar"
}
children
pane size=2 borderless=true {
plugin location="zellij:status-bar"
}
}

tab name="DERP" {
pane {
command "derper"
args "-c" "./tmp/derper-a.json" "-a" ":443" "-certmode" "manual" "-certdir" "./tmp/certs" "-hostname" "derp-a" "-mesh-psk-file" "./mesh.psk" "-mesh-with" "derp-a:443,derp-b:8443,derp-c:9443" "-stun-port" "3478" "-http-port" "-1"
}

pane {
command "derper"
args "-c" "./tmp/derper-b.json" "-a" ":8443" "-certmode" "manual" "-certdir" "./tmp/certs" "-hostname" "derp-b" "-mesh-psk-file" "./mesh.psk" "-mesh-with" "derp-a:443,derp-b:8443,derp-c:9443" "-stun-port" "3479" "-http-port" "-1"
}

pane {
command "derper"
args "-c" "./tmp/derper-c.json" "-a" ":9443" "-certmode" "manual" "-certdir" "./tmp/certs" "-hostname" "derp-c" "-mesh-psk-file" "./mesh.psk" "-mesh-with" "derp-a:443,derp-b:8443,derp-c:9443" "-stun-port" "3480" "-http-port" "-1"
}
}
}
29 changes: 23 additions & 6 deletions examples/coordinator/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func main() {
r.Use(middleware.Recoverer)

coordinator := NewTSCoordinator()
r.Handle("/*", handlers.CoordinatorHandler(coordinator))
r.Mount("/", handlers.CoordinatorHandler(coordinator))

r.Get("/nodes", NodeInfoHandler(coordinator))

Expand Down Expand Up @@ -752,11 +752,28 @@ func defaultDerpMap() tailcfg.DERPMap {
Avoid: false,
Nodes: []*tailcfg.DERPNode{
{
Name: "Embedded Loft DERP",
RegionID: 900,
HostName: "localhost",
IPv4: "127.0.0.1",
DERPPort: 3340,
Name: "Embedded Loft DERP (A)",
RegionID: 900,
HostName: "derp-a",
IPv4: "127.0.0.1",
DERPPort: 443,
CanPort80: true,
},
{
Name: "Embedded Loft DERP (B)",
RegionID: 900,
HostName: "derp-b",
IPv4: "127.0.0.1",
DERPPort: 8443,
CanPort80: false,
},
{
Name: "Embedded Loft DERP (C)",
RegionID: 900,
HostName: "derp-c",
IPv4: "127.0.0.1",
DERPPort: 9443,
CanPort80: false,
},
},
},
Expand Down
3 changes: 1 addition & 2 deletions examples/tsnet/cmd/client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ import (
"os"
"path/filepath"

"tailscale.com/envknob"
"tailscale.com/tsnet"
)

func init() {
envknob.Setenv("TS_DEBUG_USE_DERP_HTTP", "true")
// envknob.Setenv("TS_DEBUG_USE_DERP_HTTP", "true")
}

func main() {
Expand Down
3 changes: 1 addition & 2 deletions examples/tsnet/cmd/funnel/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@ import (
"log"
"net/http"

"tailscale.com/envknob"
"tailscale.com/tsnet"
"tailscale.com/types/logger"
)

func init() {
envknob.Setenv("TS_DEBUG_USE_DERP_HTTP", "true")
// envknob.Setenv("TS_DEBUG_USE_DERP_HTTP", "true")
}

func main() {
Expand Down
3 changes: 1 addition & 2 deletions examples/tsnet/cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"net/http"
"strings"

"tailscale.com/envknob"
"tailscale.com/tsnet"
)

Expand All @@ -30,7 +29,7 @@ func init() {
// envknob.Setenv("TS_DEBUG_PATCHIFY_PEER", "true")
// envknob.Setenv("TS_DEBUG_PROFILES", "true")
// envknob.Setenv("TS_DEBUG_REGISTER", "true")
envknob.Setenv("TS_DEBUG_USE_DERP_HTTP", "true")
// envknob.Setenv("TS_DEBUG_USE_DERP_HTTP", "true")
}

func main() {
Expand Down
3 changes: 1 addition & 2 deletions examples/tsnet/cmd/web-client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"net/http"

"tailscale.com/client/web"
"tailscale.com/envknob"
"tailscale.com/tsnet"
"tailscale.com/types/logger"
)
Expand All @@ -21,7 +20,7 @@ var (
)

func init() {
envknob.Setenv("TS_DEBUG_USE_DERP_HTTP", "true")
// envknob.Setenv("TS_DEBUG_USE_DERP_HTTP", "true")
}

func main() {
Expand Down
1 change: 1 addition & 0 deletions mesh.psk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
f006b43271c7ee79a9719888594de5831affc7dc369973ea09d703a735b3abcf
12 changes: 10 additions & 2 deletions tunnel_layout.kdl
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,17 @@ layout {
tab name="DERP" {
pane {
command "derper"
args "-dev" "-hostname" "localhost"
args "-c" "./tmp/derper-a.json" "-a" ":443" "-certmode" "manual" "-certdir" "./tmp/certs" "-hostname" "derp-a" "-mesh-psk-file" "./mesh.psk" "-mesh-with" "derp-a:443,derp-b:8443,derp-c:9443" "-stun-port" "3478" "-http-port" "80"
}

borderless true
pane {
command "derper"
args "-c" "./tmp/derper-b.json" "-a" ":8443" "-certmode" "manual" "-certdir" "./tmp/certs" "-hostname" "derp-b" "-mesh-psk-file" "./mesh.psk" "-mesh-with" "derp-a:443,derp-b:8443,derp-c:9443" "-stun-port" "3479" "-http-port" "-1"
}

pane {
command "derper"
args "-c" "./tmp/derper-c.json" "-a" ":9443" "-certmode" "manual" "-certdir" "./tmp/certs" "-hostname" "derp-c" "-mesh-psk-file" "./mesh.psk" "-mesh-with" "derp-a:443,derp-b:8443,derp-c:9443" "-stun-port" "3480" "-http-port" "-1"
}
}

Expand Down

0 comments on commit 8965a3e

Please sign in to comment.