add telegram timeout error connection
replace FlooWait minut to seconds add mtproxy send
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
# Build stage
|
# Build stage
|
||||||
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.21-alpine3.19 AS builder
|
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:tip-alpine3.23 AS builder
|
||||||
LABEL maintainer="Khanh Ngo <k@ndk.name>"
|
|
||||||
|
|
||||||
ARG BUILDPLATFORM
|
ARG BUILDPLATFORM
|
||||||
ARG TARGETOS
|
ARG TARGETOS
|
||||||
@@ -56,7 +55,7 @@ RUN cp -r /build/custom/ assets/
|
|||||||
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags="-X 'main.appVersion=${APP_VERSION}' -X 'main.buildTime=${BUILD_TIME}' -X 'main.gitCommit=${GIT_COMMIT}'" -a -o wg-ui .
|
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags="-X 'main.appVersion=${APP_VERSION}' -X 'main.buildTime=${BUILD_TIME}' -X 'main.gitCommit=${GIT_COMMIT}'" -a -o wg-ui .
|
||||||
|
|
||||||
# Release stage
|
# Release stage
|
||||||
FROM alpine:3.19
|
FROM alpine:latest
|
||||||
|
|
||||||
RUN addgroup -S wgui && \
|
RUN addgroup -S wgui && \
|
||||||
adduser -S -D -G wgui wgui
|
adduser -S -D -G wgui wgui
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ var (
|
|||||||
Token string
|
Token string
|
||||||
AllowConfRequest bool
|
AllowConfRequest bool
|
||||||
FloodWait int
|
FloodWait int
|
||||||
FloodWaitEnabled bool // Для отключения таймаута в ТГ
|
|
||||||
LogLevel log.Lvl
|
LogLevel log.Lvl
|
||||||
MTProxyLink string // ДОБАВИЛИ НАШУ ССЫЛКУ
|
MTProxyLink string // ДОБАВИЛИ НАШУ ССЫЛКУ
|
||||||
|
|
||||||
@@ -88,7 +87,7 @@ func Start(initDeps TgBotInitDependencies) (err error) {
|
|||||||
}
|
}
|
||||||
floodMessageSent[userid] = struct{}{}
|
floodMessageSent[userid] = struct{}{}
|
||||||
_, err := bot.SendMessage(
|
_, err := bot.SendMessage(
|
||||||
fmt.Sprintf("You can only request your configs once per %d minutes", FloodWait),
|
fmt.Sprintf("Подождите %d секунд, защита от флуда", FloodWait),
|
||||||
userid,
|
userid,
|
||||||
&echotron.MessageOptions{
|
&echotron.MessageOptions{
|
||||||
ReplyToMessageID: update.Message.ID,
|
ReplyToMessageID: update.Message.ID,
|
||||||
@@ -130,7 +129,7 @@ func SendConfig(userid int64, clientName string, confData, qrData []byte, ignore
|
|||||||
}
|
}
|
||||||
|
|
||||||
if _, wait := floodWait[userid]; wait && !ignoreFloodWait {
|
if _, wait := floodWait[userid]; wait && !ignoreFloodWait {
|
||||||
return fmt.Errorf("this client already got their config less than %d minutes ago", FloodWait)
|
return fmt.Errorf("Этот клиент будет готов получить конфиг через %d секунд", FloodWait)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !ignoreFloodWait {
|
if !ignoreFloodWait {
|
||||||
@@ -175,7 +174,7 @@ func SendConfig(userid int64, clientName string, confData, qrData []byte, ignore
|
|||||||
}
|
}
|
||||||
|
|
||||||
func updateFloodWait() {
|
func updateFloodWait() {
|
||||||
thresholdTS := time.Now().Unix() - 60*int64(FloodWait)
|
thresholdTS := time.Now().Unix() - int64(FloodWait)
|
||||||
for userid, ts := range floodWait {
|
for userid, ts := range floodWait {
|
||||||
if ts < thresholdTS {
|
if ts < thresholdTS {
|
||||||
delete(floodWait, userid)
|
delete(floodWait, userid)
|
||||||
|
|||||||
Reference in New Issue
Block a user