Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
1e195a313c
|
|||
|
f33de18007
|
|||
|
e136c30266
|
@@ -10,7 +10,7 @@ A Go-based command-line tool to manage SSH tunnels. This tool allows you to:
|
||||
## Installation
|
||||
|
||||
```
|
||||
go install git.mvl.sh/vleeuwenmenno/sshtunnel/cmd@latest
|
||||
go install git.mvl.sh/vleeuwenmenno/sshtunnel@latest
|
||||
```
|
||||
|
||||
Or clone this repository and build it yourself:
|
||||
|
||||
@@ -17,8 +17,21 @@ if ! git rev-parse --is-inside-work-tree &> /dev/null; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get the latest tag or default to v0.0.0 if no tags exist
|
||||
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
|
||||
# Fetch all tags first to ensure we have the latest
|
||||
printfe "%s\n" "cyan" "Fetching all tags..."
|
||||
log_and_run git fetch --tags
|
||||
|
||||
# Get the latest version tag, excluding 'latest' tag, or default to v0.0.0 if no tags exist
|
||||
VERSION_TAGS=$(git tag -l 'v*.*.*' | grep -v 'latest' | sort -V)
|
||||
if [ -z "$VERSION_TAGS" ]; then
|
||||
printfe "%s\n" "yellow" "No version tags found. Starting with v0.0.0."
|
||||
LATEST_TAG="v0.0.0"
|
||||
else
|
||||
# Get the latest version tag
|
||||
LATEST_TAG=$(echo "$VERSION_TAGS" | tail -n 1)
|
||||
printfe "%s" "cyan" "Found latest version tag: "
|
||||
printfe "%s\n" "yellow" "$LATEST_TAG" false
|
||||
fi
|
||||
|
||||
# Parse the version number
|
||||
if [[ $LATEST_TAG =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
|
||||
@@ -56,8 +69,7 @@ printfe "%s" "cyan" "Creating and pushing tag: "
|
||||
printfe "%s\n" "yellow" "$NEXT_VERSION" false
|
||||
|
||||
# Make sure we have the latest changes
|
||||
printfe "%s\n" "cyan" "Fetching latest tags..."
|
||||
log_and_run git fetch --tags
|
||||
# We've already fetched tags at the beginning
|
||||
|
||||
# Create the new tag
|
||||
printfe "%s\n" "cyan" "Creating new tag..."
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.mvl.sh/vleeuwenmenno/sshtunnel/pkg/stats"
|
||||
"github.com/spf13/cobra"
|
||||
"sshtunnel/pkg/stats"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -111,9 +111,9 @@ The tunnel will run in the background and can be managed using the list and stop
|
||||
fmt.Printf("Started SSH tunnel (ID: %d): localhost:%d -> %s:%d (%s) [PID: %d] [Status: %s]\n",
|
||||
id, localPort, remoteHost, remotePort, sshServer, pid, status)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
func init() {
|
||||
rootCmd.AddCommand(startCmd)
|
||||
|
||||
// Add flags for the start command
|
||||
@@ -127,7 +127,7 @@ The tunnel will run in the background and can be managed using the list and stop
|
||||
startCmd.MarkFlagRequired("local")
|
||||
startCmd.MarkFlagRequired("remote")
|
||||
startCmd.MarkFlagRequired("server")
|
||||
}
|
||||
}
|
||||
|
||||
// verifyTunnelActive checks if the tunnel is actually working
|
||||
func verifyTunnelActive(port int) bool {
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"sshtunnel/pkg/monitor"
|
||||
"sshtunnel/pkg/stats"
|
||||
"git.mvl.sh/vleeuwenmenno/sshtunnel/pkg/monitor"
|
||||
"git.mvl.sh/vleeuwenmenno/sshtunnel/pkg/stats"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"os"
|
||||
"syscall"
|
||||
|
||||
"git.mvl.sh/vleeuwenmenno/sshtunnel/pkg/stats"
|
||||
"github.com/spf13/cobra"
|
||||
"sshtunnel/pkg/stats"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
2
go.mod
2
go.mod
@@ -1,4 +1,4 @@
|
||||
module sshtunnel
|
||||
module git.mvl.sh/vleeuwenmenno/sshtunnel
|
||||
|
||||
go 1.22.2
|
||||
|
||||
|
||||
2
main.go
2
main.go
@@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"sshtunnel/cmd"
|
||||
"git.mvl.sh/vleeuwenmenno/sshtunnel/cmd"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"sshtunnel/pkg/stats"
|
||||
"git.mvl.sh/vleeuwenmenno/sshtunnel/pkg/stats"
|
||||
)
|
||||
|
||||
// Monitor represents a SSH tunnel traffic monitor
|
||||
|
||||
Reference in New Issue
Block a user