Add Kali; update repo url

This commit is contained in:
Jeffrey Serio 2024-03-29 19:59:29 -05:00
parent aeccf8d7c2
commit ef98499aa9
16 changed files with 91 additions and 54 deletions

View File

@ -11,7 +11,7 @@ export TRANSMISSION_RPC_URL=10.0.0.42
Install with Go: Install with Go:
``` bash ``` bash
go install git.sr.ht/~hyperreal/go-torrent-helper@latest go install git.hyperreal.coffee/go-torrent-helper@latest
``` ```
## Usage ## Usage

View File

@ -1,31 +0,0 @@
* go-torrent-helper
This is a helper program to add and remove torrents from a transmission-daemon instance.
To use, make sure `TRANSMISSION_RPC_URL` is exported in the shell:
#+begin_src shell
export TRANSMISSION_RPC_URL=10.0.0.42
#+end_src
Install with Go:
#+begin_src shell
go install git.sr.ht/~hyperreal/go-torrent-helper@latest
#+end_src
Example usage:
#+begin_src shell
# Add Fedora torrents
go-torrent-helper add -distro fedora -relver 38
# Remove NixOS torrents
go-torrent-helper remove -distro nixos
# Add Rocky Linux torrents
go-torrent-helper add -distro rocky -relver 9.2
# Remove older Rocky Linux torrents
go-torrent-helper remove -distro rocky -relver 8.1
# If not -relver flag is supplied for the remove subcommand, remove all torrents for given distro
go-torrent-helper remove -distro debian
#+end_src

View File

@ -4,7 +4,7 @@ import (
"fmt" "fmt"
"log" "log"
"git.sr.ht/~hyperreal/go-torrent-helper/common" "git.hyperreal.coffee/go-torrent-helper/common"
"github.com/hekmon/transmissionrpc" "github.com/hekmon/transmissionrpc"
) )

View File

@ -6,16 +6,17 @@ import (
"fmt" "fmt"
"os" "os"
"git.sr.ht/~hyperreal/go-torrent-helper/almalinux" "git.hyperreal.coffee/go-torrent-helper/almalinux"
"git.sr.ht/~hyperreal/go-torrent-helper/debian" "git.hyperreal.coffee/go-torrent-helper/debian"
"git.sr.ht/~hyperreal/go-torrent-helper/devuan" "git.hyperreal.coffee/go-torrent-helper/devuan"
"git.sr.ht/~hyperreal/go-torrent-helper/fedora" "git.hyperreal.coffee/go-torrent-helper/fedora"
"git.sr.ht/~hyperreal/go-torrent-helper/freebsd" "git.hyperreal.coffee/go-torrent-helper/freebsd"
"git.sr.ht/~hyperreal/go-torrent-helper/nixos" "git.hyperreal.coffee/go-torrent-helper/kali"
"git.sr.ht/~hyperreal/go-torrent-helper/parrot" "git.hyperreal.coffee/go-torrent-helper/nixos"
"git.sr.ht/~hyperreal/go-torrent-helper/qubes" "git.hyperreal.coffee/go-torrent-helper/parrot"
"git.sr.ht/~hyperreal/go-torrent-helper/rocky" "git.hyperreal.coffee/go-torrent-helper/qubes"
"git.sr.ht/~hyperreal/go-torrent-helper/tails" "git.hyperreal.coffee/go-torrent-helper/rocky"
"git.hyperreal.coffee/go-torrent-helper/tails"
"github.com/hekmon/transmissionrpc" "github.com/hekmon/transmissionrpc"
) )
@ -131,6 +132,7 @@ func (l *ListCmd) Run(d Distro) error {
"devuan", "devuan",
"fedora", "fedora",
"freebsd", "freebsd",
"kali",
"nixos", "nixos",
"parrot", "parrot",
"qubes", "qubes",
@ -211,6 +213,10 @@ func Root(args []string) error {
fb := &freebsd.FreeBSD{NameSubstr: "FreeBSD", Relver: relver} fb := &freebsd.FreeBSD{NameSubstr: "FreeBSD", Relver: relver}
return cmd.Run(fb) return cmd.Run(fb)
case "kali":
k := &kali.Kali{NameSubstr: "kali-linux", Relver: relver}
return cmd.Run(k)
case "nixos": case "nixos":
n := &nixos.Nixos{NameSubstr: "nixos"} n := &nixos.Nixos{NameSubstr: "nixos"}
return cmd.Run(n) return cmd.Run(n)

2
debian/main.go vendored
View File

@ -4,7 +4,7 @@ import (
"fmt" "fmt"
"log" "log"
"git.sr.ht/~hyperreal/go-torrent-helper/common" "git.hyperreal.coffee/go-torrent-helper/common"
"github.com/hekmon/transmissionrpc" "github.com/hekmon/transmissionrpc"
) )

View File

@ -4,7 +4,7 @@ import (
"fmt" "fmt"
"log" "log"
"git.sr.ht/~hyperreal/go-torrent-helper/common" "git.hyperreal.coffee/go-torrent-helper/common"
"github.com/hekmon/transmissionrpc" "github.com/hekmon/transmissionrpc"
) )

View File

@ -5,7 +5,7 @@ import (
"log" "log"
"strings" "strings"
"git.sr.ht/~hyperreal/go-torrent-helper/common" "git.hyperreal.coffee/go-torrent-helper/common"
"github.com/PuerkitoBio/goquery" "github.com/PuerkitoBio/goquery"
"github.com/hekmon/transmissionrpc" "github.com/hekmon/transmissionrpc"
) )

View File

@ -6,7 +6,7 @@ import (
"log" "log"
"strings" "strings"
"git.sr.ht/~hyperreal/go-torrent-helper/common" "git.hyperreal.coffee/go-torrent-helper/common"
"github.com/hekmon/transmissionrpc" "github.com/hekmon/transmissionrpc"
) )

2
go.mod
View File

@ -1,4 +1,4 @@
module git.sr.ht/~hyperreal/go-torrent-helper module git.hyperreal.coffee/go-torrent-helper
go 1.20 go 1.20

62
kali/main.go Normal file
View File

@ -0,0 +1,62 @@
package kali
import (
"fmt"
"log"
"strings"
"git.hyperreal.coffee/go-torrent-helper/common"
"github.com/PuerkitoBio/goquery"
"github.com/hekmon/transmissionrpc"
)
type Kali struct {
NameSubstr string
Relver string
URL string
}
func (k Kali) AddNewTorrents(transmissionbt *transmissionrpc.Client) error {
// Send HTTP GET request and receive response
k.URL = fmt.Sprintf("https://cdimage.kali.org/kali-%s/", k.Relver)
respBody, err := common.GetResponse(k.URL)
if err != nil {
return err
}
// Get a goquery doc from response body
doc, err := goquery.NewDocumentFromReader(respBody)
if err != nil {
return err
}
// Extract torrent URLs from web page source
var torrentURLs []string
doc.Find("a").Each(func(i int, s *goquery.Selection) {
if strings.Contains(s.Text(), ".torrent") {
torrentURLs = append(torrentURLs, fmt.Sprintf("%s/kali-linux-%s-%s.torrent", k.URL, k.Relver, s.Text()))
}
})
// Add torrents to Transmission instance
for _, torrentURL := range torrentURLs {
torrent, err := transmissionbt.TorrentAdd(&transmissionrpc.TorrentAddPayload{
Filename: &torrentURL,
})
if err != nil {
return err
}
log.Printf("%s added\n", *torrent.Name)
}
return nil
}
func (k Kali) RemoveOldTorrents(transmissionbt *transmissionrpc.Client) error {
if err := common.RemoveTorrents(k.NameSubstr, k.Relver, transmissionbt); err != nil {
return err
}
return nil
}

View File

@ -4,7 +4,7 @@ import (
"log" "log"
"os" "os"
"git.sr.ht/~hyperreal/go-torrent-helper/command" "git.hyperreal.coffee/go-torrent-helper/command"
) )
func main() { func main() {

View File

@ -6,7 +6,7 @@ import (
"io/ioutil" "io/ioutil"
"log" "log"
"git.sr.ht/~hyperreal/go-torrent-helper/common" "git.hyperreal.coffee/go-torrent-helper/common"
"github.com/hekmon/transmissionrpc" "github.com/hekmon/transmissionrpc"
) )

View File

@ -5,7 +5,7 @@ import (
"log" "log"
"strings" "strings"
"git.sr.ht/~hyperreal/go-torrent-helper/common" "git.hyperreal.coffee/go-torrent-helper/common"
"github.com/PuerkitoBio/goquery" "github.com/PuerkitoBio/goquery"
"github.com/hekmon/transmissionrpc" "github.com/hekmon/transmissionrpc"
) )

View File

@ -5,7 +5,7 @@ import (
"log" "log"
"strings" "strings"
"git.sr.ht/~hyperreal/go-torrent-helper/common" "git.hyperreal.coffee/go-torrent-helper/common"
"github.com/PuerkitoBio/goquery" "github.com/PuerkitoBio/goquery"
"github.com/hekmon/transmissionrpc" "github.com/hekmon/transmissionrpc"
) )

View File

@ -5,7 +5,7 @@ import (
"log" "log"
"strings" "strings"
"git.sr.ht/~hyperreal/go-torrent-helper/common" "git.hyperreal.coffee/go-torrent-helper/common"
"github.com/PuerkitoBio/goquery" "github.com/PuerkitoBio/goquery"
"github.com/hekmon/transmissionrpc" "github.com/hekmon/transmissionrpc"
) )

View File

@ -4,7 +4,7 @@ import (
"fmt" "fmt"
"log" "log"
"git.sr.ht/~hyperreal/go-torrent-helper/common" "git.hyperreal.coffee/go-torrent-helper/common"
"github.com/hekmon/transmissionrpc" "github.com/hekmon/transmissionrpc"
) )