Skip to content

Commit

Permalink
feat: Update deps, add notifier, add sitemap updater
Browse files Browse the repository at this point in the history
* Add pushbullet notifications

* Updated packages

* Added Makefile

* Added docker-compose.yaml

* Added sitemap.xml updating
  • Loading branch information
goproslowyo committed May 29, 2023
1 parent a48832d commit cd38069
Show file tree
Hide file tree
Showing 1,207 changed files with 3,860 additions and 484 deletions.
18 changes: 10 additions & 8 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
# https://docs.docker.com/engine/reference/builder/#dockerignore-file

# Exclude stream repo and repo files
infosecstreams.github.io/
.dockerignore
.git
.github
.gitignore
docker-compose.yaml
example.png
LICENSE
Makefile
README.md
SECURITY.md
StreamStatus

# Exclude "build-time" ignore files.
.dockerignore
.gcloudignore

# Exclude git history and configuration.
.gitignore
streamstatus.env
streamstatus.env.example
12 changes: 9 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@ RUN apt-get update && apt-get install -y upx ca-certificates --no-install-recomm
# Use go modules and don't let go packages call C code
ENV GO111MODULE=on CGO_ENABLED=0
WORKDIR /build
COPY . .
RUN GOOS=linux GOARCH=amd64 go build -mod=vendor -ldflags="-s -w" -o StreamStatus ./...
COPY src/ /build/
ARG VERSION
ENV VERSION=${VERSION:-unknown}
RUN GOOS=linux GOARCH=amd64 \
go build \
-mod=vendor \
-ldflags="-s -w -X main.version=${VERSION}" \
-o StreamStatus ./...

# Compress the binary and verify the output using UPX
# h/t @FiloSottile/Filippo Valsorda: https://blog.filippo.io/shrink-your-go-binaries-with-this-one-weird-trick/
RUN upx --ultra-brute /build/StreamStatus && upx -t /build/StreamStatus
RUN upx -v --lzma --best /build/StreamStatus && upx -vt /build/StreamStatus
RUN mkdir /data

# Copy the contents of /dist to the root of a scratch containter
Expand Down
39 changes: 39 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
IMAGE_NAME = ghcr.io/infosecstreams/streamstatus
IMAGE_TAG = $(shell git describe --tags --always --dirty --long)

.PHONY: help
help:
@echo "make build-ss"
@echo "make run-ss"
@echo "make push-ss"
@echo "make all"


.PHONY: build-ss
build-ss:
docker build --build-arg VERSION=$(IMAGE_TAG) -t $(IMAGE_NAME):$(IMAGE_TAG) .

.PHONY: run-ss
run-ss: build-ss
docker run -it --rm -p 8080:8080 \
-e SS_SECRETKEY=secret \
-e SS_TOKEN=token \
-e SS_USERNAME=username \
-e TW_CLIENT_ID=client_id \
-e TW_CLIENT_SECRET=client_secret \
-e SS_PUSHBULLET_APIKEY=myAPIkey \
-e SS_PUSHBULLET_DEVICES=myDevice,anotherDevice \
$(IMAGE_NAME):$(IMAGE_TAG)

.PHONY: push
push-ss: build-ss
@echo "Are you sure you want to push? [y/N] " && read ans && [ $${ans:-N} = y ]
docker tag $(IMAGE_NAME):$(IMAGE_TAG) $(IMAGE_NAME):latest
docker push $(IMAGE_NAME):$(IMAGE_TAG)
docker push $(IMAGE_NAME):latest

.PHONY: all
all: push-ss

clean:
docker rmi $(IMAGE_NAME):$(IMAGE_TAG)
47 changes: 42 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,30 @@ You need to subscribe to `stream.{offline,online}` events from the Twitch EventS
}
```

The code is bad and I feel bad.
Since Twitch removed "Hack the Box" and "TryHackMe" as categories we just look for various Cybersecurity related tags to guess if it's content we want to show as "online".

This is the current list of games and (optional) tags in the code:

```golang
var VALID_GAMES = []string{
"just chatting",
"science \u0026 technology",
"software and game development",
"talk shows \u0026 podcasts",
}

var OPTIONAL_TAGS = []string{
"ctf", "capturetheflag",
"htb", "hackthebox",
"thm", "tryhackme",
"infosec", "cybersecurity", "informationsecurity",
"hacker", "hacking", "bugbounty", "pentest", "security",
"reverseengineering", "malware", "malwareanalysis",
"iss", "infosecstream", "infosecstreams", "infosecstreamer", "infosecstreamers",
}
```

The code is ~~bad~~ okay-ish and I feel ~~bad~~ okay-ish.

## Build It

Expand All @@ -45,15 +68,25 @@ go build -mod vendor -ldflags="-s -w" -o StreamStatus ./...
Or, build a docker image:

```shell
make build-ss
# or
docker build -t streamstatus:dev .
```

## Use It

1. Update the env vars in streamstatus.env for docker-compose (check streamstatus.env.example).
1. Run it in docker:

```shell
$ make ss-run
INFO[0000] server starting on :8080
```

Run directly with ENV vars:

```shell
SS_PORT=3000 SS_SECRETKEY=secret SS_TOKEN=token SS_USERNAME=username TW_CLIENT_ID=client_id TW_CLIENT_SECRET=client_secret ./StreamStatus
SS_PORT=3000 SS_SECRETKEY=secret SS_TOKEN=token SS_USERNAME=username TW_CLIENT_ID=client_id TW_CLIENT_SECRET=client_secret SS_PUSHBULLET_APIKEY=abc123 SS_PUSHBULLET_DEVICES=phone ./StreamStatus
```

---
Expand All @@ -73,6 +106,10 @@ export SS_USERNAME=username
export TW_CLIENT_ID=client_id
# Twitch Secret
export TW_CLIENT_SECRET=client_secret
# Pushbullet API Key
export SS_PUSHBULLET_APIKEY=myAPIkey
# Pushbullet devices (comma separated) to send notifications to
export SS_PUSHBULLET_DEVICES=myDevice,anotherDevice

# Run:
./StreamStatus
Expand All @@ -83,15 +120,15 @@ export TW_CLIENT_SECRET=client_secret
Or, if you built the docker image:

```shell
docker run --rm -it -e SS_PORT=9001 -e SS_SECRETKEY=secret -e SS_TOKEN=token -e SS_USERNAME=username -e TW_CLIENT_ID=client_id -e TW_CLIENT_SECRET=client_secret streamstatus:dev
docker run --rm -it -e SS_PORT=9001 -e SS_SECRETKEY=secret -e SS_TOKEN=token -e SS_USERNAME=username -e TW_CLIENT_ID=client_id -e TW_CLIENT_SECRET=client_secret -e SS_PUSHBULLET_APIKEY=abc123 -e SS_PUSHBULLET_DEVICES=phone streamstatus:dev
```

---

Or, use `docker-compose` after setting environment variables in `streamstatus.env`

```shell
docker-compose up
docker-compose --build up
# or to background it:
docker-compose up -d
docker-compose --build up -d
```
12 changes: 9 additions & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
version: 3

version: "3"
services:
# streamstatus to receive event requests from twitch
streamstatus:
image: ghcr.io/infosecstreams/streamstatus:latest
ports:
- "8080:8080"
env_file: ./streamstatus.env
env_file: streamstatus.env
restart: always
build:
context: .
dockerfile: Dockerfile
depends_on: []
#- nginx
Loading

0 comments on commit cd38069

Please sign in to comment.