Skip to content

Commit

Permalink
Update tls usage, build.sh, add tls LICENSE
Browse files Browse the repository at this point in the history
  • Loading branch information
VHSgunzo committed Feb 8, 2024
1 parent b626530 commit d76cc2c
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 9 deletions.
8 changes: 4 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,14 @@ cd "$SRC_DIR"
export CGO_ENABLED=0
for ARCH in "${ARCHS[@]}"
do
mkdir -p "build/$ARCH"

case "$ARCH" in
source)
echo "Create archive with source code..."
git clean -fdx -e build
go mod vendor
tar -I 'zstd -T0 --ultra -22 --progress' --exclude build -cf \
"$SRC_DIR/shellsrv-src-v${VERSION}.tar.zst" -C "$SRC_DIR" .
tar -I 'zstd -T0 --ultra -22 --progress' --exclude build -l \
--exclude tls --exclude .git --exclude .github --exclude .gitignore \
-cf "$SRC_DIR/shellsrv-src-v${VERSION}.tar.zst" -C "$SRC_DIR" .
continue ;;
i386|i686) GOARCH='386' ;;
x86_64) GOARCH='amd64' ;;
Expand All @@ -48,6 +47,7 @@ for ARCH in "${ARCHS[@]}"
export GOARCH

echo "Build for ${ARCH}..."
mkdir -p "build/$ARCH"
go build -trimpath -o "build/$ARCH/shellsrv" \
-ldflags "-X main.VERSION=$VERSION -s -w -buildid="

Expand Down
21 changes: 21 additions & 0 deletions tls/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 VHSgunzo

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2 changes: 1 addition & 1 deletion tls/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ go install github.com/VHSgunzo/shellsrv@latest
## **Usage**:
```
┌──[user@linux]─[~] - Server:
└──╼ $ shellsrv -server [-tls-key key.pem] [-tls-key cert.pem] [-socket tcp:1337]
└──╼ $ shellsrv -server [-tls-key key.pem] [-tls-cert cert.pem] [-socket tcp:1337]
┌──[user@linux]─[~] - Client:
└──╼ $ shellsrv -tls [options] [ COMMAND [ arguments... ] ]
Expand Down
1 change: 0 additions & 1 deletion tls/build.sh

This file was deleted.

69 changes: 69 additions & 0 deletions tls/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/usr/bin/env bash
set -o pipefail

# WITH_UPX=1
# VERSION=0.0.1
# ARCHS=(source i386 x86_64 armv7 aarch64)
# CREATE_RELEASE_ARCHIVES=1

SRC_DIR="$(dirname "$BASH_SOURCE")"

if [ ! -n "$ARCHS" ]
then
[ -n "$1" ] && \
ARCHS=("$@")||\
ARCHS="$(uname -m)"
fi
[ "$ARCHS" == 'all' ] && \
ARCHS=(source i386 x86_64 armv7 aarch64)

GIT_VERSION="$(git describe --long --tags 2>/dev/null|sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g')"
[ -n "$GIT_VERSION" ] && \
VERSION="$GIT_VERSION"||\
VERSION="${VERSION:-HEAD}"
[ "$(basename "$(realpath "$SRC_DIR")")" == 'tls' ] && \
VERSION="${VERSION}-tls"

cd "$SRC_DIR"

export CGO_ENABLED=0
for ARCH in "${ARCHS[@]}"
do
case "$ARCH" in
source)
echo "Create archive with source code..."
git clean -fdx -e build
go mod vendor
tar -I 'zstd -T0 --ultra -22 --progress' --exclude build -l \
--exclude tls --exclude .git --exclude .github --exclude .gitignore \
-cf "$SRC_DIR/shellsrv-src-v${VERSION}.tar.zst" -C "$SRC_DIR" .
continue ;;
i386|i686) GOARCH='386' ;;
x86_64) GOARCH='amd64' ;;
armv7) GOARCH='arm' ;;
aarch64) GOARCH='arm64' ;;
*) GOARCH="$ARCH" ;;
esac
export GOARCH

echo "Build for ${ARCH}..."
mkdir -p "build/$ARCH"
go build -trimpath -o "build/$ARCH/shellsrv" \
-ldflags "-X main.VERSION=$VERSION -s -w -buildid="

if [ "$WITH_UPX" == 1 ] && command -v upx &>/dev/null
then
echo "UPXing ${ARCH}..."
upxdir="build/$ARCH/upx"
mkdir -p "$upxdir"
upx --force-overwrite -9 --best \
"build/$ARCH/shellsrv" -o "$upxdir/shellsrv"
fi

if [ "$CREATE_RELEASE_ARCHIVES" == 1 ]
then
echo "Archiving release ${ARCH}..."
tar -I 'zstd -T0 --ultra -22 --progress' -cf \
"$SRC_DIR/shellsrv-${ARCH}-v${VERSION}.tar.zst" -C "build/$ARCH" .
fi
done
1 change: 0 additions & 1 deletion tls/go.mod

This file was deleted.

11 changes: 11 additions & 0 deletions tls/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module github.com/VHSgunzo/shellsrv/tls

go 1.21.6

require (
github.com/creack/pty v1.1.21
github.com/hashicorp/yamux v0.1.1
golang.org/x/term v0.16.0
)

require golang.org/x/sys v0.16.0 // indirect
1 change: 0 additions & 1 deletion tls/go.sum

This file was deleted.

8 changes: 8 additions & 0 deletions tls/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
github.com/creack/pty v1.1.21 h1:1/QdRyBaHHJP61QkWMXlOIBfsgdDeeKfK8SYVUWJKf0=
github.com/creack/pty v1.1.21/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE=
github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ=
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.16.0 h1:m+B6fahuftsE9qjo0VWp2FW0mB3MTJvR0BaMQrq0pmE=
golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY=
2 changes: 1 addition & 1 deletion tls/shellsrv.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var VERSION string = "HEAD"
const BINARY_NAME = "shellsrv"
const UNIX_SOCKET = "unix:@shellsrv"

const USAGE_PREAMBLE = `Server usage: %[1]s -server [-tls-key key.pem] [-tls-key cert.pem] [-socket tcp:1337]
const USAGE_PREAMBLE = `Server usage: %[1]s -server [-tls-key key.pem] [-tls-cert cert.pem] [-socket tcp:1337]
Client usage: %[1]s -tls [options] [ COMMAND [ arguments... ] ]
If COMMAND is not passed, spawn a $SHELL on the server side.
Expand Down

0 comments on commit d76cc2c

Please sign in to comment.