update log

This commit is contained in:
nikk gitanes
2021-08-23 20:27:17 +03:00
parent ebe547a566
commit 6775ded8ae
6 changed files with 28 additions and 15 deletions

View File

@@ -214,7 +214,7 @@ func SetSettings(set *sets.BTSets) {
}
lockApi.Lock()
defer lockApi.Unlock()
log.TLogln("drop all")
log.TLogln("drop all torrents")
dropAllTorrent()
time.Sleep(time.Second * 2)
log.TLogln("disconect")
@@ -222,6 +222,7 @@ func SetSettings(set *sets.BTSets) {
sets.SetBTSets(set)
log.TLogln("connect")
bts.Connect()
time.Sleep(time.Second * 2)
log.TLogln("end set settings")
}
@@ -231,11 +232,16 @@ func SetDefSettings() {
}
lockApi.Lock()
defer lockApi.Unlock()
log.TLogln("drop all torrents")
dropAllTorrent()
time.Sleep(time.Second * 2)
log.TLogln("disconect")
bts.Disconnect()
sets.SetDefault()
log.TLogln("connect")
bts.Connect()
time.Sleep(time.Second * 5)
time.Sleep(time.Second * 2)
log.TLogln("end set default settings")
}
func dropAllTorrent() {

View File

@@ -48,10 +48,12 @@ func (t *Torrent) Stream(fileID int, req *http.Request, resp http.ResponseWriter
reader := t.NewReader(file)
host, port, err := net.SplitHostPort(req.RemoteAddr)
if err != nil {
log.Println("Connect client")
} else {
log.Println("Connect client", host, port)
if sets.BTsets.EnableDebug {
if err != nil {
log.Println("Connect client")
} else {
log.Println("Connect client", host, port)
}
}
sets.SetViewed(&sets.Viewed{t.Hash().HexString(), fileID})
@@ -62,10 +64,12 @@ func (t *Torrent) Stream(fileID int, req *http.Request, resp http.ResponseWriter
http.ServeContent(resp, req, file.Path(), time.Unix(t.Timestamp, 0), reader)
t.CloseReader(reader)
if err != nil {
log.Println("Disconnect client")
} else {
log.Println("Disconnect client", host, port)
if sets.BTsets.EnableDebug {
if err != nil {
log.Println("Disconnect client")
} else {
log.Println("Disconnect client", host, port)
}
}
return nil
}