Updating torrent library to latest, fixing breaking changes to torrent library api
This commit is contained in:
@@ -32,8 +32,8 @@ func CreateServerPushMessage(message ServerPushMessage, conn *websocket.Conn) {
|
|||||||
conn.WriteJSON(message)
|
conn.WriteJSON(message)
|
||||||
}
|
}
|
||||||
|
|
||||||
func QueueJSONMessage(conn *websocket.Conn){
|
func QueueJSONMessage(conn *websocket.Conn) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//RefreshSingleRSSFeed refreshing a single RSS feed to send to the client (so no updating database) mainly by updating the torrent list to display any changes
|
//RefreshSingleRSSFeed refreshing a single RSS feed to send to the client (so no updating database) mainly by updating the torrent list to display any changes
|
||||||
@@ -332,8 +332,8 @@ func CreateRunningTorrentArray(tclient *torrent.Client, TorrentLocalArray []*Sto
|
|||||||
PercentDone := fmt.Sprintf("%.2f", float32(calculatedCompletedSize)/float32(calculatedTotalSize))
|
PercentDone := fmt.Sprintf("%.2f", float32(calculatedCompletedSize)/float32(calculatedTotalSize))
|
||||||
fullClientDB.TorrentHash = TempHash
|
fullClientDB.TorrentHash = TempHash
|
||||||
fullClientDB.PercentDone = PercentDone
|
fullClientDB.PercentDone = PercentDone
|
||||||
fullClientDB.DataBytesRead = fullStruct.ConnStats.BytesReadData //used for calculations not passed to client calculating up/down speed
|
fullClientDB.DataBytesRead = fullStruct.ConnStats.BytesReadData.Int64() //used for calculations not passed to client calculating up/down speed
|
||||||
fullClientDB.DataBytesWritten = fullStruct.ConnStats.BytesWrittenData //used for calculations not passed to client calculating up/down speed
|
fullClientDB.DataBytesWritten = fullStruct.ConnStats.BytesWrittenData.Int64() //used for calculations not passed to client calculating up/down speed
|
||||||
fullClientDB.ActivePeers = activePeersString + " / (" + totalPeersString + ")"
|
fullClientDB.ActivePeers = activePeersString + " / (" + totalPeersString + ")"
|
||||||
fullClientDB.TorrentHashString = TempHash.String()
|
fullClientDB.TorrentHashString = TempHash.String()
|
||||||
fullClientDB.TorrentName = singleTorrentFromStorage.TorrentName
|
fullClientDB.TorrentName = singleTorrentFromStorage.TorrentName
|
||||||
@@ -347,7 +347,7 @@ func CreateRunningTorrentArray(tclient *torrent.Client, TorrentLocalArray []*Sto
|
|||||||
TempHash := singleTorrent.InfoHash()
|
TempHash := singleTorrent.InfoHash()
|
||||||
if previousElement.TorrentHashString == TempHash.String() { //matching previous to new
|
if previousElement.TorrentHashString == TempHash.String() { //matching previous to new
|
||||||
CalculateTorrentSpeed(singleTorrent, fullClientDB, previousElement, calculatedCompletedSize)
|
CalculateTorrentSpeed(singleTorrent, fullClientDB, previousElement, calculatedCompletedSize)
|
||||||
fullClientDB.TotalUploadedBytes = singleTorrentFromStorage.UploadedBytes + (fullStruct.ConnStats.BytesWrittenData - previousElement.DataBytesWritten)
|
fullClientDB.TotalUploadedBytes = singleTorrentFromStorage.UploadedBytes + (fullStruct.ConnStats.BytesWrittenData.Int64() - previousElement.DataBytesWritten)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -109,7 +109,7 @@ func CalculateTorrentSpeed(t *torrent.Torrent, c *ClientDB, oc ClientDB, complet
|
|||||||
dt := float32(now.Sub(oc.UpdatedAt)) // get the delta time length between now and last updated
|
dt := float32(now.Sub(oc.UpdatedAt)) // get the delta time length between now and last updated
|
||||||
db := float32(bytes - oc.BytesCompleted) //getting the delta bytes
|
db := float32(bytes - oc.BytesCompleted) //getting the delta bytes
|
||||||
rate := db * (float32(time.Second) / dt) // converting into seconds
|
rate := db * (float32(time.Second) / dt) // converting into seconds
|
||||||
dbU := float32(bytesUpload - oc.DataBytesWritten)
|
dbU := float32(bytesUpload.Int64() - oc.DataBytesWritten)
|
||||||
rateUpload := dbU * (float32(time.Second) / dt)
|
rateUpload := dbU * (float32(time.Second) / dt)
|
||||||
if rate >= 0 {
|
if rate >= 0 {
|
||||||
rateMB := rate / 1024 / 1024 //creating MB to calculate ETA
|
rateMB := rate / 1024 / 1024 //creating MB to calculate ETA
|
||||||
@@ -331,6 +331,27 @@ func ValidateQueues(db *storm.DB, config Settings.FullClientSettings, tclient *t
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
torrentQueues = Storage.FetchQueues(db)
|
||||||
|
for _, singleTorrent := range tclient.Torrents() { //If we have a queued torrent that is missing data, and an active torrent that is seeding, then prioritize the missing data one
|
||||||
|
for _, queuedTorrent := range torrentQueues.QueuedTorrents {
|
||||||
|
if singleTorrent.InfoHash().String() == queuedTorrent {
|
||||||
|
if singleTorrent.BytesMissing() > 0 {
|
||||||
|
for _, activeTorrent := range torrentQueues.ActiveTorrents {
|
||||||
|
for _, singleActiveTorrent := range tclient.Torrents() {
|
||||||
|
if activeTorrent == singleActiveTorrent.InfoHash().String() {
|
||||||
|
if singleActiveTorrent.Seeding() == true {
|
||||||
|
singleTorrentFromStorage := Storage.FetchTorrentFromStorage(db, activeTorrent)
|
||||||
|
RemoveTorrentFromActive(&singleTorrentFromStorage, singleActiveTorrent, db)
|
||||||
|
singleTorrentFromStorage = Storage.FetchTorrentFromStorage(db, queuedTorrent)
|
||||||
|
AddTorrentToActive(&singleTorrentFromStorage, singleTorrent, db)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//CalculateTorrentStatus is used to determine what the STATUS column of the frontend will display ll2
|
//CalculateTorrentStatus is used to determine what the STATUS column of the frontend will display ll2
|
||||||
|
@@ -4,6 +4,7 @@ import (
|
|||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"fmt"
|
"fmt"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"golang.org/x/time/rate"
|
"golang.org/x/time/rate"
|
||||||
@@ -34,7 +35,7 @@ type FullClientSettings struct {
|
|||||||
LoggingLevel logrus.Level
|
LoggingLevel logrus.Level
|
||||||
LoggingOutput string
|
LoggingOutput string
|
||||||
Version int
|
Version int
|
||||||
TorrentConfig torrent.Config `json:"-"`
|
TorrentConfig torrent.ClientConfig `json:"-"`
|
||||||
TFileUploadFolder string
|
TFileUploadFolder string
|
||||||
SeedRatioStop float64
|
SeedRatioStop float64
|
||||||
DefaultMoveFolder string
|
DefaultMoveFolder string
|
||||||
@@ -55,9 +56,9 @@ func defaultConfig() FullClientSettings {
|
|||||||
Config.HTTPAddr = ":8000"
|
Config.HTTPAddr = ":8000"
|
||||||
Config.SeedRatioStop = 1.50
|
Config.SeedRatioStop = 1.50
|
||||||
|
|
||||||
Config.TorrentConfig.DHTConfig = dht.ServerConfig{
|
//Config.TorrentConfig.DhtStartingNodes = dht.StartingNodesGetter{
|
||||||
StartingNodes: dht.GlobalBootstrapAddrs,
|
// StartingNodes: dht.GlobalBootstrapAddrs,
|
||||||
}
|
//}
|
||||||
|
|
||||||
return Config
|
return Config
|
||||||
}
|
}
|
||||||
@@ -201,13 +202,17 @@ func FullClientSettingsNew() FullClientSettings {
|
|||||||
disableIPv6 := viper.GetBool("torrentClientConfig.DisableIPv6")
|
disableIPv6 := viper.GetBool("torrentClientConfig.DisableIPv6")
|
||||||
debug := viper.GetBool("torrentClientConfig.Debug")
|
debug := viper.GetBool("torrentClientConfig.Debug")
|
||||||
|
|
||||||
dhtServerConfig := dht.ServerConfig{
|
//dhtServerConfig := dht.StartingNodesGetter()
|
||||||
StartingNodes: dht.GlobalBootstrapAddrs,
|
|
||||||
}
|
//if viper.IsSet("DHTConfig") {
|
||||||
if viper.IsSet("DHTConfig") {
|
// fmt.Println("Reading in custom DHT config")
|
||||||
fmt.Println("Reading in custom DHT config")
|
// dhtServerConfig = dhtServerSettings(dhtServerConfig)
|
||||||
dhtServerConfig = dhtServerSettings(dhtServerConfig)
|
//}
|
||||||
|
httpAddrPortInt64, err := strconv.ParseInt(httpAddrPort, 10, 0)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Failed creating 64-bit integer for goTorrent Port!", err)
|
||||||
}
|
}
|
||||||
|
httpAddrPortInt := int(httpAddrPortInt64) //converting to integer
|
||||||
|
|
||||||
encryptionPolicy := torrent.EncryptionPolicy{
|
encryptionPolicy := torrent.EncryptionPolicy{
|
||||||
DisableEncryption: viper.GetBool("EncryptionPolicy.DisableEncryption"),
|
DisableEncryption: viper.GetBool("EncryptionPolicy.DisableEncryption"),
|
||||||
@@ -215,22 +220,24 @@ func FullClientSettingsNew() FullClientSettings {
|
|||||||
PreferNoEncryption: viper.GetBool("EncryptionPolicy.PreferNoEncryption"),
|
PreferNoEncryption: viper.GetBool("EncryptionPolicy.PreferNoEncryption"),
|
||||||
}
|
}
|
||||||
|
|
||||||
tConfig := torrent.Config{
|
tConfig := torrent.NewDefaultClientConfig()
|
||||||
DataDir: dataDirAbs,
|
|
||||||
ListenAddr: listenAddr,
|
tConfig.DataDir = dataDirAbs
|
||||||
DisablePEX: disablePex,
|
tConfig.ListenPort = httpAddrPortInt
|
||||||
NoDHT: noDHT,
|
tConfig.DisablePEX = disablePex
|
||||||
DHTConfig: dhtServerConfig,
|
tConfig.NoDHT = noDHT
|
||||||
NoUpload: noUpload,
|
tConfig.NoUpload = noUpload
|
||||||
Seed: seed,
|
tConfig.Seed = seed
|
||||||
UploadRateLimiter: uploadRateLimiter,
|
tConfig.UploadRateLimiter = uploadRateLimiter
|
||||||
DownloadRateLimiter: downloadRateLimiter,
|
tConfig.DownloadRateLimiter = downloadRateLimiter
|
||||||
PeerID: peerID,
|
tConfig.PeerID = peerID
|
||||||
DisableUTP: disableUTP,
|
tConfig.DisableUTP = disableUTP
|
||||||
DisableTCP: disableTCP,
|
tConfig.DisableTCP = disableTCP
|
||||||
DisableIPv6: disableIPv6,
|
tConfig.DisableIPv6 = disableIPv6
|
||||||
Debug: debug,
|
tConfig.Debug = debug
|
||||||
EncryptionPolicy: encryptionPolicy,
|
tConfig.EncryptionPolicy = encryptionPolicy
|
||||||
|
if listenAddr != "" {
|
||||||
|
tConfig.SetListenAddr(listenAddr) //Setting the IP address to listen on
|
||||||
}
|
}
|
||||||
|
|
||||||
Config := FullClientSettings{
|
Config := FullClientSettings{
|
||||||
@@ -248,7 +255,7 @@ func FullClientSettingsNew() FullClientSettings {
|
|||||||
PushBulletToken: pushBulletToken,
|
PushBulletToken: pushBulletToken,
|
||||||
},
|
},
|
||||||
TFileUploadFolder: "uploadedTorrents",
|
TFileUploadFolder: "uploadedTorrents",
|
||||||
TorrentConfig: tConfig,
|
TorrentConfig: *tConfig,
|
||||||
DefaultMoveFolder: defaultMoveFolderAbs,
|
DefaultMoveFolder: defaultMoveFolderAbs,
|
||||||
TorrentWatchFolder: torrentWatchFolderAbs,
|
TorrentWatchFolder: torrentWatchFolderAbs,
|
||||||
MaxActiveTorrents: maxActiveTorrents,
|
MaxActiveTorrents: maxActiveTorrents,
|
||||||
|
Reference in New Issue
Block a user