Play some more with torrenting

Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
Miek Gieben
2020-07-27 15:55:31 +02:00
parent ef33425487
commit 37e6038788
12 changed files with 277 additions and 19 deletions

View File

@@ -14,12 +14,12 @@ func init() { plugin.Register("torrent", setup) }
func setup(c *caddy.Controller) error {
tor, err := parse(c)
if err != nil {
return plugin.Error("sign", err)
return plugin.Error("torrent", err)
}
c.OnStartup(func() error {
// go tor.do()
return nil
err := tor.Do()
return err
})
c.OnShutdown(func() error {
close(tor.stop)
@@ -31,7 +31,7 @@ func setup(c *caddy.Controller) error {
}
func parse(c *caddy.Controller) (*Torrent, error) {
t := &Torrent{}
t := &Torrent{stop: make(chan struct{})}
config := dnsserver.GetConfig(c)
for c.Next() {
@@ -46,8 +46,8 @@ func parse(c *caddy.Controller) (*Torrent, error) {
for c.NextBlock() {
switch c.Val() {
case "seed":
t.seed = true
case "dht":
t.dht = true
default:
return nil, c.Errf("unknown property '%s'", c.Val())
}