Fix up magnet links
Cette révision appartient à :
Parent
f7dd28387a
révision
079f5db825
2 fichiers modifiés avec 17 ajouts et 13 suppressions
|
@ -55,7 +55,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{.Name}}</td>
|
<td>{{.Name}}</td>
|
||||||
<td>{{.Hash}}</td>
|
<td>{{.Hash}}</td>
|
||||||
<td><a href="{{.Magnet}}"><span class="glyphicon glyphicon-magnet" aria-hidden="true"></span></a>
|
<td><a href="{{.Magnet}}" target="_blank" title="Magnet link" ><span class="glyphicon glyphicon-magnet" aria-hidden="true"></span></a>
|
||||||
<a href="http://torcache.net/torrent/{{.Hash}}.torrent"><span class="glyphicon glyphicon-floppy-save" aria-hidden="true"></span></a>
|
<a href="http://torcache.net/torrent/{{.Hash}}.torrent"><span class="glyphicon glyphicon-floppy-save" aria-hidden="true"></span></a>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
|
|
22
main.go
22
main.go
|
@ -18,6 +18,7 @@ import (
|
||||||
var dbHandle *sql.DB
|
var dbHandle *sql.DB
|
||||||
var templates = template.Must(template.ParseFiles("index.html"))
|
var templates = template.Must(template.ParseFiles("index.html"))
|
||||||
var debugLogger *log.Logger
|
var debugLogger *log.Logger
|
||||||
|
var trackers = "&tr=udp://zer0day.to:1337/announce&tr=udp://tracker.leechers-paradise.org:6969&tr=udp://explodie.org:6969&tr=udp://tracker.opentrackr.org:1337&tr=udp://tracker.coppersurfer.tk:6969"
|
||||||
|
|
||||||
type Record struct {
|
type Record struct {
|
||||||
Records []Records `json: "records"`
|
Records []Records `json: "records"`
|
||||||
|
@ -29,7 +30,7 @@ type Records struct {
|
||||||
Id string `json: "id"`
|
Id string `json: "id"`
|
||||||
Name string `json: "name"`
|
Name string `json: "name"`
|
||||||
Hash string `json: "hash"`
|
Hash string `json: "hash"`
|
||||||
Magnet string `json: "magnet"`
|
Magnet template.URL `json: "magnet"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func getDBHandle() *sql.DB {
|
func getDBHandle() *sql.DB {
|
||||||
|
@ -55,12 +56,12 @@ func apiHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var id, name, hash, magnet string
|
var id, name, hash, magnet string
|
||||||
rows.Scan(&id, &name, &hash)
|
rows.Scan(&id, &name, &hash)
|
||||||
magnet = "magnet:?xt=urn:btih:" + hash + "&dn=" + url.QueryEscape(name) + "&tr=udp://tracker.openbittorrent.com"
|
magnet = "magnet:?xt=urn:btih:" + hash + "&dn=" + url.QueryEscape(name) + trackers
|
||||||
res := Records{
|
res := Records{
|
||||||
Id: id,
|
Id: id,
|
||||||
Name: name,
|
Name: name,
|
||||||
Hash: hash,
|
Hash: hash,
|
||||||
Magnet: magnet}
|
Magnet: safe(magnet)}
|
||||||
|
|
||||||
b.Records = append(b.Records, res)
|
b.Records = append(b.Records, res)
|
||||||
|
|
||||||
|
@ -85,12 +86,12 @@ func singleapiHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var id, name, hash, magnet string
|
var id, name, hash, magnet string
|
||||||
rows.Scan(&id, &name, &hash)
|
rows.Scan(&id, &name, &hash)
|
||||||
magnet = "magnet:?xt=urn:btih:" + hash + "&dn=" + url.QueryEscape(name) + "&tr=udp://tracker.openbittorrent.com"
|
magnet = "magnet:?xt=urn:btih:" + hash + "&dn=" + url.QueryEscape(name) + trackers
|
||||||
res := Records{
|
res := Records{
|
||||||
Id: id,
|
Id: id,
|
||||||
Name: name,
|
Name: name,
|
||||||
Hash: hash,
|
Hash: hash,
|
||||||
Magnet: magnet}
|
Magnet: safe(magnet)}
|
||||||
|
|
||||||
b.Records = append(b.Records, res)
|
b.Records = append(b.Records, res)
|
||||||
|
|
||||||
|
@ -117,12 +118,12 @@ func searchHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var id, name, hash, magnet string
|
var id, name, hash, magnet string
|
||||||
rows.Scan(&id, &name, &hash)
|
rows.Scan(&id, &name, &hash)
|
||||||
magnet = "magnet:?xt=urn:btih:" + hash + "&dn=" + url.QueryEscape(name) + "&tr=udp://tracker.openbittorrent.com"
|
magnet = "magnet:?xt=urn:btih:" + hash + "&dn=" + url.QueryEscape(name) + trackers
|
||||||
res := Records{
|
res := Records{
|
||||||
Id: id,
|
Id: id,
|
||||||
Name: name,
|
Name: name,
|
||||||
Hash: hash,
|
Hash: hash,
|
||||||
Magnet: magnet}
|
Magnet: safe(magnet)}
|
||||||
|
|
||||||
b.Records = append(b.Records, res)
|
b.Records = append(b.Records, res)
|
||||||
|
|
||||||
|
@ -134,6 +135,9 @@ func searchHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
func safe(s string) template.URL {
|
||||||
|
return template.URL(s)
|
||||||
|
}
|
||||||
|
|
||||||
func rootHandler(w http.ResponseWriter, r *http.Request) {
|
func rootHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
|
@ -144,12 +148,12 @@ func rootHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var id, name, hash, magnet string
|
var id, name, hash, magnet string
|
||||||
rows.Scan(&id, &name, &hash)
|
rows.Scan(&id, &name, &hash)
|
||||||
magnet = "magnet:?xt=urn:btih:" + hash + "&dn=" + url.QueryEscape(name) + "&tr=udp://tracker.openbittorrent.com"
|
magnet = "magnet:?xt=urn:btih:" + hash + "&dn=" + url.QueryEscape(name) + trackers
|
||||||
res := Records{
|
res := Records{
|
||||||
Id: id,
|
Id: id,
|
||||||
Name: name,
|
Name: name,
|
||||||
Hash: hash,
|
Hash: hash,
|
||||||
Magnet: magnet}
|
Magnet: safe(magnet)}
|
||||||
|
|
||||||
b.Records = append(b.Records, res)
|
b.Records = append(b.Records, res)
|
||||||
|
|
||||||
|
|
Référencer dans un nouveau ticket