update
This commit is contained in:
parent
af29d6a85c
commit
7b0e9fc59e
138
RaceNotifier.go
138
RaceNotifier.go
@ -1,10 +1,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
"os"
|
||||
)
|
||||
|
||||
@ -27,97 +23,77 @@ type PreRace struct {
|
||||
|
||||
func main() {
|
||||
|
||||
file, err := os.OpenFile("racer.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0777)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
// wrt := io.MultiWriter(os.Stdout, file)
|
||||
log.SetOutput(file)
|
||||
defer file.Close()
|
||||
// file, err := os.OpenFile("racer.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0777)
|
||||
// if err != nil {
|
||||
// log.Fatal(err)
|
||||
// }
|
||||
|
||||
log.Println("Starting Program")
|
||||
// log.SetOutput(file)
|
||||
// defer file.Close()
|
||||
|
||||
if len(os.Args) == 0 {
|
||||
log.Println("Program launched without args")
|
||||
os.Exit(0)
|
||||
}
|
||||
// log.Println("Starting Program")
|
||||
os.Exit(0)
|
||||
// if os.Args[1] == "PreRace" || os.Args[1] == "Prerace" || os.Args[1] == "prerace" {
|
||||
|
||||
if len(os.Args) == 1 {
|
||||
log.Println("Program launched with 1 arg")
|
||||
os.Exit(0)
|
||||
}
|
||||
// // This is a pre race, need to find all the details of the release
|
||||
// log.Printf("[PreRace] Prerace launched with details %v, %v, %v", os.Args[1], os.Args[2], os.Args[3])
|
||||
// r := PreRace{Name: os.Args[2], Indexer: os.Args[3]}
|
||||
|
||||
if len(os.Args) == 2 {
|
||||
log.Println("Program launched with 2 arg")
|
||||
os.Exit(0)
|
||||
}
|
||||
// tcpAddr, err := net.ResolveTCPAddr("tcp", "212.7.203.107:3000")
|
||||
// if err != nil {
|
||||
// log.Fatal("Could not parse IP address:", err)
|
||||
// }
|
||||
// conn, err := net.DialTCP("tcp", nil, tcpAddr)
|
||||
// if err != nil {
|
||||
// log.Fatal("Could not connect:", err)
|
||||
// }
|
||||
|
||||
if len(os.Args) == 3 {
|
||||
log.Println("Program launched with 3 arg")
|
||||
os.Exit(0)
|
||||
}
|
||||
// defer conn.Close()
|
||||
|
||||
if os.Args[1] == "PreRace" || os.Args[1] == "Prerace" || os.Args[1] == "prerace" {
|
||||
// _, err = conn.Write([]byte(r.Indexer + " " + r.Name))
|
||||
// if err != nil {
|
||||
// log.Fatal("Could not send message: ", err)
|
||||
// }
|
||||
// log.Println("Message sent...")
|
||||
|
||||
// This is a pre race, need to find all the details of the release
|
||||
log.Printf("[PreRace] Prerace launched with details %v, %v, %v", os.Args[1], os.Args[2], os.Args[3])
|
||||
r := PreRace{Name: os.Args[2], Indexer: os.Args[3]}
|
||||
// os.Exit(0)
|
||||
|
||||
tcpAddr, err := net.ResolveTCPAddr("tcp", "212.7.203.107:3000")
|
||||
if err != nil {
|
||||
log.Fatal("Could not parse IP address:", err)
|
||||
}
|
||||
conn, err := net.DialTCP("tcp", nil, tcpAddr)
|
||||
if err != nil {
|
||||
log.Fatal("Could not connect:", err)
|
||||
}
|
||||
// } else if os.Args[1] == "test" {
|
||||
// for n, args := range os.Args {
|
||||
// log.Println("Arg", n, "->", args)
|
||||
// }
|
||||
|
||||
defer conn.Close()
|
||||
// } else {
|
||||
// // This is the race thus the torrent has finished downloading.
|
||||
// r := Race{Name: os.Args[1], Category: os.Args[2], Content_Path: os.Args[3], Root_Path: os.Args[4], Save_Path: os.Args[5], Hash: os.Args[6], Size: os.Args[7], Files: os.Args[8]}
|
||||
// data, err := json.Marshal(r)
|
||||
|
||||
_, err = conn.Write([]byte(r.Indexer + " " + r.Name))
|
||||
if err != nil {
|
||||
log.Fatal("Could not send message: ", err)
|
||||
}
|
||||
log.Println("Message sent...")
|
||||
// if err != nil {
|
||||
// fmt.Println(err)
|
||||
// }
|
||||
|
||||
os.Exit(0)
|
||||
// err = os.WriteFile("test.json", data, 0644)
|
||||
// if err != nil {
|
||||
// log.Fatal(err)
|
||||
// }
|
||||
|
||||
} else if os.Args[1] == "test" {
|
||||
for n, args := range os.Args {
|
||||
log.Println("Arg", n, "->", args)
|
||||
}
|
||||
// tcpAddr, err := net.ResolveTCPAddr("tcp", "212.7.203.107:3000")
|
||||
// if err != nil {
|
||||
// log.Fatal("Could not parse IP address:", err)
|
||||
// }
|
||||
// conn, err := net.DialTCP("tcp", nil, tcpAddr)
|
||||
// if err != nil {
|
||||
// log.Fatal("Could not connect:", err)
|
||||
// }
|
||||
|
||||
} else {
|
||||
// This is the race thus the torrent has finished downloading.
|
||||
r := Race{Name: os.Args[1], Category: os.Args[2], Content_Path: os.Args[3], Root_Path: os.Args[4], Save_Path: os.Args[5], Hash: os.Args[6], Size: os.Args[7], Files: os.Args[8]}
|
||||
data, err := json.Marshal(r)
|
||||
// defer conn.Close()
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
// _, err = conn.Write([]byte(data))
|
||||
// if err != nil {
|
||||
// log.Fatal("Could not send message: ", err)
|
||||
// }
|
||||
|
||||
err = os.WriteFile("test.json", data, 0644)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
// os.Exit(0)
|
||||
|
||||
tcpAddr, err := net.ResolveTCPAddr("tcp", "212.7.203.107:3000")
|
||||
if err != nil {
|
||||
log.Fatal("Could not parse IP address:", err)
|
||||
}
|
||||
conn, err := net.DialTCP("tcp", nil, tcpAddr)
|
||||
if err != nil {
|
||||
log.Fatal("Could not connect:", err)
|
||||
}
|
||||
|
||||
defer conn.Close()
|
||||
|
||||
_, err = conn.Write([]byte(data))
|
||||
if err != nil {
|
||||
log.Fatal("Could not send message: ", err)
|
||||
}
|
||||
|
||||
os.Exit(0)
|
||||
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user