mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 13:05:46 +00:00
24d41e4ae7
1. Add TCP port forwarding. For example: ./sniproxy -forwards=tcp/22/github.com will forward SSH to github. % ssh -i ~/.ssh/id_ecdsa.pem -T git@github.com Hi GitHubUser! You've successfully authenticated, but GitHub does not provide shell access. % ssh -i ~/.ssh/id_ecdsa.pem -T git@100.65.x.y Hi GitHubUser! You've successfully authenticated, but GitHub does not provide shell access. 2. Additionally export clientmetrics as prometheus metrics for local scraping over the tailnet: http://sniproxy-hostname:8080/debug/varz Updates https://github.com/tailscale/tailscale/issues/1748 Signed-off-by: Denton Gentry <dgentry@tailscale.com>
38 lines
1006 B
Go
38 lines
1006 B
Go
// Copyright (c) Tailscale Inc & AUTHORS
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
package main
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/google/go-cmp/cmp"
|
|
)
|
|
|
|
func TestPortForwardingArguments(t *testing.T) {
|
|
tests := []struct {
|
|
in string
|
|
wanterr string
|
|
want *portForward
|
|
}{
|
|
{"", "", nil},
|
|
{"bad port specifier", "cannot parse", nil},
|
|
{"tcp/xyz/example.com", "bad forwarding port", nil},
|
|
{"tcp//example.com", "bad forwarding port", nil},
|
|
{"tcp/2112/", "bad destination", nil},
|
|
{"udp/53/example.com", "unsupported forwarding protocol", nil},
|
|
{"tcp/22/github.com", "", &portForward{Proto: "tcp", Port: 22, Destination: "github.com"}},
|
|
}
|
|
for _, tt := range tests {
|
|
got, goterr := parseForward(tt.in)
|
|
if tt.wanterr != "" {
|
|
if !strings.Contains(goterr.Error(), tt.wanterr) {
|
|
t.Errorf("f(%q).err = %v; want %v", tt.in, goterr, tt.wanterr)
|
|
}
|
|
} else if diff := cmp.Diff(got, tt.want); diff != "" {
|
|
t.Errorf("Parsed forward (-got, +want):\n%s", diff)
|
|
}
|
|
}
|
|
}
|