Add cgi-bin

This commit is contained in:
Jeffrey Serio 2023-04-01 21:21:31 -05:00
parent 638f628798
commit 9ccc7efde7

View File

@ -68,7 +68,10 @@ type TorrentInfo struct {
}
func main() {
transmissionbt, err := transmissionrpc.New(os.Getenv("RPC_HOST"), os.Getenv("RPC_USER"), os.Getenv("RPC_PASSWD"), nil)
fmt.Println("20 text/gemini\r")
fmt.Println("```")
transmissionbt, err := transmissionrpc.New("192.168.122.121", "", "", nil)
if err != nil {
log.Fatalln(err)
}
@ -86,10 +89,18 @@ func main() {
{"Torrent count", fmt.Sprintf("%d", stats.TorrentCount)},
}
fmt.Println("SESSION STATS")
fmt.Println()
sessionStatsTable := tablewriter.NewWriter(os.Stdout)
sessionStatsTable.SetAlignment(tablewriter.ALIGN_LEFT)
sessionStatsTable.SetBorder(false)
sessionStatsTable.SetCenterSeparator("│")
sessionStatsTable.SetColumnSeparator("│")
sessionStatsTable.SetRowLine(true)
sessionStatsTable.SetRowSeparator("─")
sessionStatsTable.AppendBulk(sessionStats)
sessionStatsTable.Render()
fmt.Println()
currentStats := [][]string{
{"Uploaded bytes", fmt.Sprintf("%s", byteCountIEC(stats.CurrentStats.UploadedBytes))},
@ -99,10 +110,18 @@ func main() {
{"Time active", convertTime(stats.CurrentStats.SecondsActive)},
}
fmt.Println("CURRENT STATS")
fmt.Println()
currentStatsTable := tablewriter.NewWriter(os.Stdout)
currentStatsTable.SetAlignment(tablewriter.ALIGN_LEFT)
currentStatsTable.SetBorder(false)
currentStatsTable.SetCenterSeparator("│")
currentStatsTable.SetColumnSeparator("│")
currentStatsTable.SetRowLine(true)
currentStatsTable.SetRowSeparator("─")
currentStatsTable.AppendBulk(currentStats)
currentStatsTable.Render()
fmt.Println()
cumulativeStats := [][]string{
{"Uploaded bytes", fmt.Sprintf("%s", byteCountIEC(stats.CumulativeStats.UploadedBytes))},
@ -112,10 +131,18 @@ func main() {
{"Time active", convertTime(stats.CumulativeStats.SecondsActive)},
}
fmt.Println("CUMULATIVE STATS")
fmt.Println()
cumulativeStatsTable := tablewriter.NewWriter(os.Stdout)
cumulativeStatsTable.SetAlignment(tablewriter.ALIGN_LEFT)
cumulativeStatsTable.SetBorder(false)
cumulativeStatsTable.SetCenterSeparator("│")
cumulativeStatsTable.SetColumnSeparator("│")
cumulativeStatsTable.SetRowLine(true)
cumulativeStatsTable.SetRowSeparator("─")
cumulativeStatsTable.AppendBulk(cumulativeStats)
cumulativeStatsTable.Render()
fmt.Println()
var torrentInfo = []TorrentInfo{}
torrents, err := transmissionbt.TorrentGet([]string{"name", "addedDate", "totalSize", "peersConnected", "peersGettingFromUs"}, nil)
@ -131,12 +158,19 @@ func main() {
return torrentInfo[i].Name < torrentInfo[j].Name
})
fmt.Println("TORRENT INFO")
fmt.Println()
torrentStatsTable := tablewriter.NewWriter(os.Stdout)
torrentStatsTable.SetHeader([]string{"Name", "Date Added", "Total Size", "Peers Connected", "Peers Getting From Us"})
torrentStatsTable.SetAlignment(tablewriter.ALIGN_LEFT)
torrentStatsTable.SetBorder(false)
torrentStatsTable.SetCenterSeparator("│")
torrentStatsTable.SetColumnSeparator("│")
torrentStatsTable.SetRowLine(true)
torrentStatsTable.SetRowSeparator("─")
for _, v := range torrentInfo {
torrentStatsTable.Append([]string{v.Name, fmt.Sprintf("%s", v.DateAdded), fmt.Sprintf("%d", v.TotalSize), fmt.Sprintf("%d", v.PeersConnected), fmt.Sprintf("%d", v.PeersGettingFromUs)})
torrentStatsTable.Append([]string{v.Name, fmt.Sprintf("%s", v.DateAdded), byteCountIEC(int64(v.TotalSize)), fmt.Sprintf("%d", v.PeersConnected), fmt.Sprintf("%d", v.PeersGettingFromUs)})
}
torrentStatsTable.Render()