Skip to content

Commit eb00a0f

Browse files
author
Simple-Tracker
committed
Bug fix
1 parent ec40ccf commit eb00a0f

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

README.en.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ Docker version is configured through the same name variable configuration, which
147147
| ignoreFailureExit | bool | false | Ignore failure exit. If enabled, it will continue to retry after first detection of the client fails or authentication fails |
148148
| sleepTime | uint32 | 20 (MicroSec) | Query waiting time of each Torrent Peers. Short interval can make blocking Peer faster but may cause client lag, Long interval can help average CPU usage |
149149
| timeout | uint32 | 6 (MillSec) | Request timeout. If interval is too short, peer may not be properly blocked. If interval is too long, timeout request will affect blocking other peer |
150-
| proxy | string | Auto | Use proxy. Proxy will still automatically detect proxy on first load. Empty: Disable proxy; Auto: Automatic (use proxy only for external resources); All: Use proxy |
150+
| proxy | string | Auto | Use proxy. Still automatically detect proxy on first load. Empty: Disable proxy; Auto: Automatic (use proxy only for external resources); All: Use proxy |
151151
| longConnection | bool | true | Long connection. Enable to reduce resource consumption |
152152
| logPath | string | logs | Log path. Must enable logToFile |
153153
| logToFile | bool | true | Log general information to file. If enabled, it can be used for general analysis and statistical purposes |

request.go

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88

99
var fetchFailedCount = 0
1010

11-
func NewRequest(isPOST bool, url string, postdata string, external bool, withHeader *map[string]string) *http.Request {
11+
func NewRequest(isPOST bool, url string, postdata string, clientReq bool, withHeader *map[string]string) *http.Request {
1212
var request *http.Request
1313
var err error
1414

@@ -47,26 +47,28 @@ func NewRequest(isPOST bool, url string, postdata string, external bool, withHea
4747
request.Header.Set("Content-Type", "application/x-www-form-urlencoded")
4848
}
4949

50-
if currentClientType == "Transmission" && external && Tr_csrfToken != "" {
51-
request.Header.Set("X-Transmission-Session-Id", Tr_csrfToken)
52-
}
50+
if clientReq {
51+
if currentClientType == "Transmission" && Tr_csrfToken != "" {
52+
request.Header.Set("X-Transmission-Session-Id", Tr_csrfToken)
53+
}
5354

54-
if external && config.UseBasicAuth && config.ClientUsername != "" {
55-
request.SetBasicAuth(config.ClientUsername, config.ClientPassword)
55+
if config.UseBasicAuth && config.ClientUsername != "" {
56+
request.SetBasicAuth(config.ClientUsername, config.ClientPassword)
57+
}
5658
}
5759

5860
return request
5961
}
60-
func Fetch(url string, tryLogin bool, external bool, withHeader *map[string]string) (int, http.Header, []byte) {
61-
request := NewRequest(false, url, "", external, withHeader)
62+
func Fetch(url string, tryLogin bool, clientReq bool, withHeader *map[string]string) (int, http.Header, []byte) {
63+
request := NewRequest(false, url, "", clientReq, withHeader)
6264
if request == nil {
6365
return -1, nil, nil
6466
}
6567

6668
var response *http.Response
6769
var err error
6870

69-
if external {
71+
if clientReq {
7072
response, err = httpClient.Do(request)
7173
} else {
7274
response, err = httpClientExternal.Do(request)
@@ -141,16 +143,16 @@ func Fetch(url string, tryLogin bool, external bool, withHeader *map[string]stri
141143

142144
return response.StatusCode, response.Header, responseBody
143145
}
144-
func Submit(url string, postdata string, tryLogin bool, external bool, withHeader *map[string]string) (int, http.Header, []byte) {
145-
request := NewRequest(true, url, postdata, external, withHeader)
146+
func Submit(url string, postdata string, tryLogin bool, clientReq bool, withHeader *map[string]string) (int, http.Header, []byte) {
147+
request := NewRequest(true, url, postdata, clientReq, withHeader)
146148
if request == nil {
147149
return -1, nil, nil
148150
}
149151

150152
var response *http.Response
151153
var err error
152154

153-
if external {
155+
if clientReq {
154156
response, err = httpClient.Do(request)
155157
} else {
156158
response, err = httpClientExternal.Do(request)

0 commit comments

Comments
 (0)