2020-06-29 08:43:46 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
set -u
|
|
|
|
|
|
|
|
source .env
|
|
|
|
|
2020-07-18 05:28:12 +00:00
|
|
|
#go generate -mod=vendor ./...
|
2020-07-20 15:27:31 +00:00
|
|
|
VENDOR_ID="${VENDOR_ID:-"${VENDOR_ID:-"test-id"}"}"
|
2020-07-18 05:28:12 +00:00
|
|
|
CLIENT_SECRET="${CLIENT_SECRET:-}"
|
2020-07-22 08:05:30 +00:00
|
|
|
#go build -mod=vendor -o ./telebit \
|
2020-11-05 22:07:01 +00:00
|
|
|
# -ldflags="-X 'main.VendorID=$VENDOR_ID' -X 'main.ClientSecret=$CLIENT_SECRET' -X 'main.serviceName=telebit' -X 'main.serviceDesc=securely tunnel through telebit.io'" \
|
2020-07-18 05:28:12 +00:00
|
|
|
# cmd/telebit/*.go
|
2020-11-13 09:43:17 +00:00
|
|
|
pushd cmd/telebit
|
|
|
|
go build -mod=vendor -o telebit .
|
|
|
|
popd
|
2020-07-18 05:28:12 +00:00
|
|
|
|
|
|
|
# For Device Authorization across services
|
2020-07-22 08:05:30 +00:00
|
|
|
#AUTH_URL=${AUTH_URL:-"https://devices.examples.com/api"}
|
2020-07-20 15:27:31 +00:00
|
|
|
VENDOR_ID="$VENDOR_ID"
|
2020-07-18 05:28:12 +00:00
|
|
|
SECRET="${CLIENT_SECRET:-"xxxxxxxxxxxxxxxx"}"
|
|
|
|
#CLIENT_SECRET=${CLIENT_SECRET:-"yyyyyyyyyyyyyyyy"}
|
|
|
|
LOCALS="${LOCALS:-"https:newbie.devices.examples.com:3000,http:newbie.devices.examples.com:3000"}"
|
|
|
|
|
|
|
|
# For the Remote Server (Tunnel Client)
|
|
|
|
TUNNEL_RELAY_URL=${TUNNEL_RELAY_URL:-"wss://devices.example.com"}
|
|
|
|
LISTEN=":3080"
|
|
|
|
|
|
|
|
# For Let's Encrypt / ACME registration
|
|
|
|
ACME_AGREE=${ACME_AGREE:-}
|
|
|
|
ACME_EMAIL=${ACME_EMAIL:-"me@example.com"}
|
|
|
|
|
|
|
|
# For Let's Encrypt / ACME challenges
|
|
|
|
ACME_RELAY_URL=${ACME_RELAY_URL:-"https://devices.examples.com/api/dns"}
|
|
|
|
|
|
|
|
VERBOSE=${VERBOSE:-}
|
|
|
|
VERBOSE_BYTES=${VERBOSE_BYTES:-}
|
|
|
|
VERBOSE_RAW=${VERBOSE_RAW:-}
|
|
|
|
|
|
|
|
|
|
|
|
./telebit \
|
2020-07-20 15:27:31 +00:00
|
|
|
--vendor-id "$VENDOR_ID" \
|
2020-07-18 05:28:12 +00:00
|
|
|
--secret "$CLIENT_SECRET" \
|
2020-07-18 05:41:08 +00:00
|
|
|
--tunnel-relay-url $TUNNEL_RELAY_URL \
|
2020-07-18 05:28:12 +00:00
|
|
|
--listen "$LISTEN" \
|
2020-08-13 08:34:39 +00:00
|
|
|
--tls-locals "$TLS_LOCALS" \
|
2020-07-18 05:28:12 +00:00
|
|
|
--locals "$LOCALS" \
|
|
|
|
--acme-agree=${ACME_AGREE} \
|
|
|
|
--acme-email "$ACME_EMAIL" \
|
|
|
|
--verbose=$VERBOSE
|
|
|
|
|
2020-07-22 08:05:30 +00:00
|
|
|
# --auth-url $AUTH_URL \
|
|
|
|
# --acme-relay-url $ACME_RELAY_URL \
|
2020-07-18 05:28:12 +00:00
|
|
|
# --subject "$CLIENT_SUBJECT" \
|
2020-06-29 08:43:46 +00:00
|
|
|
|
2020-07-18 05:28:12 +00:00
|
|
|
#PORT_FORWARDS=3443:3001,8443:3002
|