Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
d2be1c0
chore(docker): update Go base image to 1.25-alpine3.21
EverythingSuckz Oct 11, 2025
bdde1a5
chore(goreleaser): update version to 2 in configuration
EverythingSuckz Oct 11, 2025
f1dcca4
refactor: update to gotgproto `v1.0.0-beta21`
EverythingSuckz Oct 11, 2025
6f2380b
style: format adjustments in build.yml for consistency
EverythingSuckz Feb 7, 2026
3b80f1c
chore(release): restrict tag pattern to versioned tags (v*)
EverythingSuckz Feb 7, 2026
33b17a4
chore: replace log.Panic with log.Sugar().Fatalf for error handling i…
EverythingSuckz Feb 8, 2026
3204d5a
feat(pipe): better streaming with prefetching blocks
EverythingSuckz Feb 10, 2026
0353127
fix(pipe): handle unexpected nil blocks during prefetch
EverythingSuckz Feb 10, 2026
d97c8cc
fix(pipe): adjust block trimming logic in prefetch for accurate data …
EverythingSuckz Feb 10, 2026
762ab14
feat(config): add support for configuring stream parameters via comma…
EverythingSuckz Feb 10, 2026
b91a4be
fix(stream): handle stream pipe creation errors in getStreamRoute
EverythingSuckz Feb 10, 2026
0806811
fix(pipe): implement max backoff for block download retries to preven…
EverythingSuckz Feb 10, 2026
9a40063
feat(pipe): better streaming with prefetching blocks (#188)
EverythingSuckz Feb 10, 2026
75cb174
fix(stream): suppress logging of client disconnect errors during stre…
EverythingSuckz Feb 10, 2026
2d5fdd1
Merge pull request #189 from EverythingSuckz:fix/supress-known-errors
EverythingSuckz Feb 10, 2026
01a4bcd
chore(main): update version string to `3.2.0-alpha1`
EverythingSuckz Feb 10, 2026
48eeae1
fix(release): update goreleaser action version and standardize string…
EverythingSuckz Feb 10, 2026
0229788
feat(build): add docker metadata step and streamline image tagging
EverythingSuckz Feb 10, 2026
e500ff9
fix(goreleaser): correct archives format due of deprecation error
EverythingSuckz Feb 10, 2026
6d9033b
feat(build): add image description label for Docker metadata
EverythingSuckz Feb 10, 2026
2193377
feat(release): add GitHub release configuration with auto prerelease
EverythingSuckz Feb 10, 2026
cf468fc
feat(release): merge docker releases into goreleaser
EverythingSuckz Feb 10, 2026
21fcd32
fix(release): correct syntax error in GoReleaser args
EverythingSuckz Feb 11, 2026
aad5cba
fix(release): update Docker tags to conditionally include 'latest' fo…
EverythingSuckz Feb 11, 2026
2d54f58
fix(go.mod): update Go version from 1.24.0 to 1.25.0
EverythingSuckz Feb 11, 2026
60837c1
fix(start): correct typo in response message for file upload instruction
EverythingSuckz Feb 11, 2026
f20e15a
fix(stream): improve error handling for unexpected update structures …
EverythingSuckz Feb 11, 2026
952f0bc
fix(run): initialize logger and load config before starting the server
EverythingSuckz Feb 16, 2026
fcdc2d8
feat(timing): add TimeFuncWithResult utility for logging function exe…
EverythingSuckz Feb 16, 2026
81f3379
refactor(stream): enhance getStreamRoute and downloadBlockWithRetry w…
EverythingSuckz Feb 16, 2026
12a976a
feat(logger): show ms in logs when in debug mode
EverythingSuckz Feb 16, 2026
1e3e244
fix(pipe): validate range in NewStreamPipe to prevent invalid input
EverythingSuckz Feb 16, 2026
6b33bab
fix(stream): remove internal server error response on stream pipe cre…
EverythingSuckz Feb 16, 2026
af07676
chore(docker): update base image to golang:1.25
EverythingSuckz Feb 16, 2026
724960c
chore(timing): change log level to debug for execution time logging
EverythingSuckz Feb 16, 2026
35dc098
chore(workflows): update `actions/checkout` and `actions/setup-go` to…
EverythingSuckz Feb 16, 2026
f8db191
chore(workflows): update Go version to 1.25 in release workflow
EverythingSuckz Feb 16, 2026
9b2ee22
feat(stream): handle CDN redirect in downloadBlock function
EverythingSuckz Feb 16, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 0 additions & 53 deletions .github/workflows/build.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/notify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
notify:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v6
- name: Notify the commit on Telegram.
uses: EverythingSuckz/github-telegram-notify@main
with:
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ on:
workflow_dispatch:
inputs:
goReleaserArgs:
description: 'Args goreleaser'
description: "Args goreleaser"
required: false
default: '--clean'
default: "--clean"
push:
tags:
- "*"
- "v*"

permissions:
contents: write
Expand All @@ -19,26 +19,26 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v6
with:
fetch-depth: 0
- run: git fetch --force --tags
- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v6
with:
go-version: 1.21
go-version: 1.25
- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: latest
args: release ${{ github.event.inputs.goReleaserArgs }}"
args: release ${{ github.event.inputs.goReleaserArgs }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
41 changes: 37 additions & 4 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 1
version: 2
project_name: TG-FileStreamBot
env:
- GO111MODULE=on
Expand All @@ -23,12 +23,39 @@ builds:
- arm64
mod_timestamp: '{{ .CommitTimestamp }}'

dockers_v2:
- images:
- "ghcr.io/everythingsuckz/fsb"

tags:
- "{{ .Tag }}"
- "v{{ .Major }}.{{ .Minor }}"
- "{{ if not .Prerelease }}latest{{ end }}"

dockerfile: Dockerfile

platforms:
- linux/amd64
- linux/arm64
labels:
"org.opencontainers.image.name": "{{.ProjectName}}"
"org.opencontainers.image.created": "{{.Date}}"
"org.opencontainers.image.revision": "{{.FullCommit}}"
"org.opencontainers.image.version": "{{.Version}}"
"org.opencontainers.image.description": "A high-performance Telegram File Streamer Bot written in Go. Stream files directly from Telegram to your download manager or media player with extreme efficiency."
"org.opencontainers.image.source": "{{.GitURL}}"

retry:
attempts: 5
delay: 10
max_delay: 10
Comment thread
coderabbitai[bot] marked this conversation as resolved.

archives:
- format: tar.gz
- formats: ["tar.gz"]
name_template: "{{ .ProjectName }}-{{ .Tag }}-{{ .Os }}-{{ .Arch }}"
format_overrides:
- goos: windows
format: zip
formats: ["zip"]

signs:
- artifacts: checksum
Expand All @@ -50,4 +77,10 @@ changelog:
filters:
exclude:
- "^docs:"
- "^test:"
- "^test:"

release:
github:
owner: EverythingSuckz
name: TG-FileStreamBot
prerelease: auto
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.21-alpine3.18 as builder
FROM golang:1.25-alpine3.21 as builder
Comment thread
EverythingSuckz marked this conversation as resolved.
RUN apk update && apk upgrade --available && sync
WORKDIR /app
COPY . .
Expand Down
2 changes: 1 addition & 1 deletion cmd/fsb/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/spf13/cobra"
)

const versionString = "3.1.0"
const versionString = "3.2.0-alpha1"

var rootCmd = &cobra.Command{
Use: "fsb [command]",
Expand Down
12 changes: 7 additions & 5 deletions cmd/fsb/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,24 @@ var runCmd = &cobra.Command{
var startTime time.Time = time.Now()

func runApp(cmd *cobra.Command, args []string) {
// initialize logger early so config loading is logged to file
utils.InitLogger(false)
config.Load(utils.Logger, cmd)
// reinitialize with correct dev mode
utils.InitLogger(config.ValueOf.Dev)
log := utils.Logger
mainLogger := log.Named("Main")
mainLogger.Info("Starting server")
config.Load(log, cmd)
router := getRouter(log)

mainBot, err := bot.StartClient(log)
if err != nil {
log.Panic("Failed to start main bot", zap.Error(err))
log.Sugar().Fatalf("Failed to start main bot: %v", err)
}
cache.InitCache(log)
workers, err := bot.StartWorkers(log)
if err != nil {
log.Panic("Failed to start workers", zap.Error(err))
return
log.Sugar().Fatalf("Failed to start workers: %v", err)
}
workers.AddDefaultClient(mainBot, mainBot.Self)
bot.StartUserBot(log)
Expand All @@ -51,7 +53,7 @@ func runApp(cmd *cobra.Command, args []string) {
mainLogger.Sugar().Infof("Server is running at %s", config.ValueOf.Host)
err = router.Run(fmt.Sprintf(":%d", config.ValueOf.Port))
if err != nil {
mainLogger.Sugar().Fatalln(err)
mainLogger.Sugar().Fatalf("Server failed to start: %v", err)
}
}

Expand Down
42 changes: 42 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ type config struct {
UsePublicIP bool `envconfig:"USE_PUBLIC_IP" default:"false"`
AllowedUsers allowedUsers `envconfig:"ALLOWED_USERS"`
MultiTokens []string

// stream specific config
StreamConcurrency int `envconfig:"STREAM_CONCURRENCY" default:"4"`
StreamBufferCount int `envconfig:"STREAM_BUFFER_COUNT" default:"8"`
StreamTimeoutSec int `envconfig:"STREAM_TIMEOUT_SEC" default:"30"`
StreamMaxRetries int `envconfig:"STREAM_MAX_RETRIES" default:"3"`
}

var botTokenRegex = regexp.MustCompile(`MULTI\_TOKEN\d+=(.*)`)
Expand Down Expand Up @@ -84,6 +90,10 @@ func SetFlagsFromConfig(cmd *cobra.Command) {
cmd.Flags().String("user-session", ValueOf.UserSession, "Pyrogram user session")
cmd.Flags().Bool("use-public-ip", ValueOf.UsePublicIP, "Use public IP instead of local IP")
cmd.Flags().String("multi-token-txt-file", "", "Multi token txt file (Not implemented)")
cmd.Flags().Int("stream-concurrency", ValueOf.StreamConcurrency, "Number of parallel block fetches")
cmd.Flags().Int("stream-buffer-count", ValueOf.StreamBufferCount, "Number of blocks to prefetch")
cmd.Flags().Int("stream-timeout-sec", ValueOf.StreamTimeoutSec, "Maximum time to wait for a single block (in seconds)")
cmd.Flags().Int("stream-max-retries", ValueOf.StreamMaxRetries, "Number of retry attempts for failed fetches")
}

func (c *config) loadConfigFromArgs(log *zap.Logger, cmd *cobra.Command) {
Expand Down Expand Up @@ -136,6 +146,22 @@ func (c *config) loadConfigFromArgs(log *zap.Logger, cmd *cobra.Command) {
os.Setenv("MULTI_TOKEN_TXT_FILE", multiTokens)
// TODO: Add support for importing tokens from a separate file
}
streamConcurrency, _ := cmd.Flags().GetInt("stream-concurrency")
if streamConcurrency != 0 {
os.Setenv("STREAM_CONCURRENCY", strconv.Itoa(streamConcurrency))
}
streamBufferCount, _ := cmd.Flags().GetInt("stream-buffer-count")
if streamBufferCount != 0 {
os.Setenv("STREAM_BUFFER_COUNT", strconv.Itoa(streamBufferCount))
}
streamTimeoutSec, _ := cmd.Flags().GetInt("stream-timeout-sec")
if streamTimeoutSec != 0 {
os.Setenv("STREAM_TIMEOUT_SEC", strconv.Itoa(streamTimeoutSec))
}
streamMaxRetries, _ := cmd.Flags().GetInt("stream-max-retries")
if streamMaxRetries != 0 {
os.Setenv("STREAM_MAX_RETRIES", strconv.Itoa(streamMaxRetries))
}
}

func (c *config) setupEnvVars(log *zap.Logger, cmd *cobra.Command) {
Expand Down Expand Up @@ -189,6 +215,22 @@ func Load(log *zap.Logger, cmd *cobra.Command) {
log.Sugar().Info("HASH_LENGTH can't be less than 5, defaulting to 6")
ValueOf.HashLength = 6
}
if ValueOf.StreamConcurrency <= 0 {
log.Sugar().Info("STREAM_CONCURRENCY must be greater than 0, defaulting to 4")
ValueOf.StreamConcurrency = 4
}
if ValueOf.StreamBufferCount <= 0 {
log.Sugar().Info("STREAM_BUFFER_COUNT must be greater than 0, defaulting to 8")
ValueOf.StreamBufferCount = 8
}
if ValueOf.StreamTimeoutSec <= 0 {
log.Sugar().Info("STREAM_TIMEOUT_SEC must be greater than 0, defaulting to 30 seconds")
ValueOf.StreamTimeoutSec = 30
}
if ValueOf.StreamMaxRetries <= 0 {
log.Sugar().Info("STREAM_MAX_RETRIES must be greater than 0, defaulting to 3")
ValueOf.StreamMaxRetries = 3
}
}

func getIP(public bool) (string, error) {
Expand Down
54 changes: 33 additions & 21 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,51 +1,63 @@
module EverythingSuckz/fsb

go 1.21.3
go 1.25.0
Comment thread
EverythingSuckz marked this conversation as resolved.

require (
github.com/celestix/gotgproto v1.0.0-beta18
github.com/celestix/gotgproto v1.0.0-beta21
github.com/gin-gonic/gin v1.9.1
github.com/gotd/td v0.105.0
github.com/glebarez/sqlite v1.11.0
github.com/gotd/td v0.132.0
github.com/joho/godotenv v1.5.1
github.com/kelseyhightower/envconfig v1.4.0
github.com/quantumsheep/range-parser v1.1.0
github.com/spf13/cobra v1.8.0
)

require (
github.com/AnimeKaizoku/cacher v1.0.1 // indirect
github.com/AnimeKaizoku/cacher v1.0.3 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chenzhuoyu/iasm v0.9.1 // indirect
github.com/coder/websocket v1.8.14 // indirect
github.com/dlclark/regexp2 v1.11.5 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/fatih/color v1.18.0 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/glebarez/go-sqlite v1.22.0 // indirect
github.com/glebarez/sqlite v1.11.0 // indirect
github.com/go-faster/errors v0.7.1 // indirect
github.com/go-faster/jx v1.1.0 // indirect
github.com/go-faster/xor v1.0.0 // indirect
github.com/go-faster/yaml v0.4.6 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gotd/ige v0.2.2 // indirect
github.com/gotd/neo v0.1.5 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/ncruces/go-strftime v0.1.9 // indirect
github.com/klauspost/compress v1.18.0 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/ncruces/go-strftime v1.0.0 // indirect
github.com/ogen-go/ogen v1.16.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/segmentio/asm v1.2.0 // indirect
github.com/segmentio/asm v1.2.1 // indirect
github.com/shopspring/decimal v1.4.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
go.opentelemetry.io/otel v1.28.0 // indirect
go.opentelemetry.io/otel/trace v1.28.0 // indirect
go.opentelemetry.io/otel v1.38.0 // indirect
go.opentelemetry.io/otel/metric v1.38.0 // indirect
go.opentelemetry.io/otel/trace v1.38.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/sync v0.7.0 // indirect
gorm.io/gorm v1.25.11 // indirect
modernc.org/libc v1.55.2 // indirect
modernc.org/mathutil v1.6.0 // indirect
modernc.org/memory v1.8.0 // indirect
modernc.org/sqlite v1.30.2 // indirect
nhooyr.io/websocket v1.8.11 // indirect
golang.org/x/exp v0.0.0-20251009144603-d2f985daa21b // indirect
golang.org/x/mod v0.29.0 // indirect
golang.org/x/sync v0.17.0 // indirect
golang.org/x/tools v0.38.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gorm.io/gorm v1.31.0 // indirect
modernc.org/libc v1.66.10 // indirect
modernc.org/mathutil v1.7.1 // indirect
modernc.org/memory v1.11.0 // indirect
modernc.org/sqlite v1.39.1 // indirect
rsc.io/qr v0.2.0 // indirect
)

Expand All @@ -72,10 +84,10 @@ require (
github.com/ugorji/go/codec v1.2.12 // indirect
go.uber.org/zap v1.27.0
golang.org/x/arch v0.7.0 // indirect
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/crypto v0.43.0 // indirect
golang.org/x/net v0.46.0 // indirect
golang.org/x/sys v0.37.0 // indirect
golang.org/x/text v0.30.0 // indirect
golang.org/x/time v0.5.0
google.golang.org/protobuf v1.32.0 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1
Expand Down
Loading