status merged
Cette révision appartient à :
Parent
7624ccc2ef
révision
e878811508
1 fichiers modifiés avec 27 ajouts et 25 suppressions
32
main.go
32
main.go
|
@ -10,7 +10,6 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
@ -19,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 {
|
||||||
Category string `json: "category"`
|
Category string `json: "category"`
|
||||||
|
@ -32,7 +32,7 @@ type Records struct {
|
||||||
Name string `json: "name"`
|
Name string `json: "name"`
|
||||||
Status int `json: "status"`
|
Status int `json: "status"`
|
||||||
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 {
|
||||||
|
@ -44,7 +44,6 @@ func getDBHandle() *sql.DB {
|
||||||
func checkErr(err error) {
|
func checkErr(err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
debugLogger.Println(" " + err.Error())
|
debugLogger.Println(" " + err.Error())
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,14 +57,14 @@ 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
|
||||||
var status int
|
var status int
|
||||||
rows.Scan(&id, &name, &hash)
|
rows.Scan(&id, &name, &status, &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,
|
||||||
Status: status,
|
Status: status,
|
||||||
Hash: hash,
|
Hash: hash,
|
||||||
Magnet: magnet}
|
Magnet: safe(magnet)}
|
||||||
|
|
||||||
b.Records = append(b.Records, res)
|
b.Records = append(b.Records, res)
|
||||||
|
|
||||||
|
@ -90,14 +89,14 @@ 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
|
||||||
var status int
|
var status int
|
||||||
rows.Scan(&id, &name, &hash)
|
rows.Scan(&id, &name, &status, &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,
|
||||||
Status: status,
|
Status: status,
|
||||||
Hash: hash,
|
Hash: hash,
|
||||||
Magnet: magnet}
|
Magnet: safe(magnet)}
|
||||||
|
|
||||||
b.Records = append(b.Records, res)
|
b.Records = append(b.Records, res)
|
||||||
|
|
||||||
|
@ -130,14 +129,14 @@ 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
|
||||||
var status int
|
var status int
|
||||||
rows.Scan(&id, &name, &hash)
|
rows.Scan(&id, &name, &status, &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,
|
||||||
Status: status,
|
Status: status,
|
||||||
Hash: hash,
|
Hash: hash,
|
||||||
Magnet: magnet}
|
Magnet: safe(magnet)}
|
||||||
|
|
||||||
b.Records = append(b.Records, res)
|
b.Records = append(b.Records, res)
|
||||||
|
|
||||||
|
@ -149,6 +148,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)
|
||||||
|
@ -159,14 +161,14 @@ 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
|
||||||
var status int
|
var status int
|
||||||
rows.Scan(&id, &name, &hash)
|
rows.Scan(&id, &name, &status, &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,
|
||||||
Status: status,
|
Status: status,
|
||||||
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