From 84fc16357e88d3308c2c42c94368337d9b2d026d Mon Sep 17 00:00:00 2001 From: hulb Date: Sat, 15 Aug 2020 10:50:50 +0800 Subject: [PATCH 1/2] type assert fix --- getter/tgchannel.go | 14 +++++++++++--- getter/web_fanqiangdang.go | 15 ++++++++++++--- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/getter/tgchannel.go b/getter/tgchannel.go index 74ab98e..c03f046 100644 --- a/getter/tgchannel.go +++ b/getter/tgchannel.go @@ -22,14 +22,22 @@ type TGChannelGetter struct { func NewTGChannelGetter(options tool.Options) Getter { num, found := options["num"] - if !found || num.(int) <= 0 { - num = 200 + t := 200 + switch num.(type) { + case int: + t = num.(int) + case float64: + t = int(num.(float64)) + } + + if !found || t <= 0 { + t = 200 } url, found := options["channel"] if found { return &TGChannelGetter{ c: colly.NewCollector(), - NumNeeded: num.(int), + NumNeeded: t, Url: "https://t.me/s/" + url.(string), } } diff --git a/getter/web_fanqiangdang.go b/getter/web_fanqiangdang.go index 3554c45..588866d 100644 --- a/getter/web_fanqiangdang.go +++ b/getter/web_fanqiangdang.go @@ -22,14 +22,23 @@ type WebFanqiangdang struct { func NewWebFanqiangdangGetter(options tool.Options) Getter { num, found := options["num"] - if !found || num.(int) <= 0 { - num = 200 + + t := 200 + switch num.(type) { + case int: + t = num.(int) + case float64: + t = int(num.(float64)) + } + + if !found || t <= 0 { + t = 200 } url, found := options["url"] if found { return &WebFanqiangdang{ c: colly.NewCollector(), - NumNeeded: num.(int), + NumNeeded: t, Url: url.(string), } } From ff3f5ae893616ad91e5cc5e1ca6c464d501f1203 Mon Sep 17 00:00:00 2001 From: hulb Date: Sat, 15 Aug 2020 11:43:14 +0800 Subject: [PATCH 2/2] fix Dockerfile --- Dockerfile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8cf5c35..754d6b7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,5 +10,8 @@ RUN go mod download && \ FROM alpine:latest RUN apk add --no-cache ca-certificates -COPY --from=builder /proxypool / -ENTRYPOINT ["/proxypool"] \ No newline at end of file +WORKDIR /proxypool-src +COPY ./assets /proxypool-src/assets +COPY ./source.yaml /proxypool-src +COPY --from=builder /proxypool /proxypool-src/ +ENTRYPOINT ["/proxypool-src/proxypool"]