Skip to content
This repository has been archived by the owner on Mar 5, 2021. It is now read-only.

Commit

Permalink
refresh endpoint was calling wrong function
Browse files Browse the repository at this point in the history
  • Loading branch information
nicksherron committed Feb 5, 2020
1 parent fd7937c commit 0760667
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func API() {
if busy {
c.String(http.StatusConflict, "busy")
} else {
go DownloadProxies()
go DownloadInit()
c.String(http.StatusOK, "ok")
}
})
Expand Down
6 changes: 6 additions & 0 deletions internal/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,23 +158,29 @@ func dbCacheStats() {
//--------------------------------------------------------------------------------------

func loadDb(proxy *Proxy) {
defer mutex.Unlock()
_, err := DB.Exec(`insert into proxies("created_at", "updated_at", "check_count", "country", "fail_count",
"last_status", "proxy", "timeout_count", "source", "success_count", "anonymous", "losing_streak")
VALUES($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12)
ON CONFLICT (proxy) DO UPDATE SET updated_at = EXCLUDED.updated_at
`, time.Now(), time.Now(), proxy.CheckCount, proxy.Country, proxy.FailCount,
proxy.LastStatus, proxy.Proxy, proxy.TimeoutCount, proxy.Source, proxy.SuccessCount, proxy.Anonymous, proxy.LosingStreak)
mutex.Lock()
if err != nil {
log.Fatal(err)
}
}

func dbInsert(proxy *Proxy) {
defer mutex.Unlock()

_, err := DB.Exec(`update proxies SET "updated_at" = $1, "check_count" = $2 ,"fail_count" = $3,
"last_status" = $4, "timeout_count" = $5, "success_count" = $6, "losing_streak" = $7,
"deleted" = $8, "anonymous" = $9 , "proxy" = $10, judge = $11, "resp_time" = $12 where id = $13`,
time.Now(), proxy.CheckCount, proxy.FailCount, proxy.LastStatus, proxy.TimeoutCount,
proxy.SuccessCount, proxy.LosingStreak, proxy.Deleted, proxy.Anonymous, proxy.Proxy, proxy.Judge, proxy.RespTime, proxy.ID)
mutex.Lock()

if err != nil {
log.Println(err)
}
Expand Down
3 changes: 3 additions & 0 deletions internal/providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,7 @@ func proxylistDownloadP(ctx context.Context) Proxies {
start := time.Now()
var (
foundProxies Proxies
mu sync.Mutex
source = "proxy-list.download"
urls = []string{
"https://www.proxy-list.download/api/v1/get?type=http",
Expand All @@ -728,7 +729,9 @@ func proxylistDownloadP(ctx context.Context) Proxies {
continue
}
p := Proxy{Proxy: proxy, Source: source}
mu.Unlock()
foundProxies = append(foundProxies, &p)
mu.Unlock()
}
done <- true
}
Expand Down

0 comments on commit 0760667

Please sign in to comment.