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