-
Notifications
You must be signed in to change notification settings - Fork 2
/
test2.go
91 lines (81 loc) · 1.7 KB
/
test2.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package main
import (
"bufio"
"fmt"
"io/ioutil"
"net"
"os"
"os/exec"
"servehttp"
"strings"
"time"
"update"
)
type decIden struct {
ipAddr net.TCPAddr
}
var globalIden []decIden
func main() {
updeTime, reqHeader, err := update.UpdateNUtv()
if err != nil {
fmt.Errorf("Error found in updating your NUtv app%v", err)
}
go servehttp.ServeHttp()
_ = updeTime
fmt.Println(reqHeader.MyAddr.String())
// var dataChannel chan string
addr := strings.Split(reqHeader.MyAddr.String(), "/")
tcpAddr, err := net.ResolveTCPAddr("tcp", fmt.Sprintf("%s:6969", addr[0]))
l, err := net.ListenTCP("tcp", tcpAddr)
if err != nil {
fmt.Errorf("not able to listen%v", err)
}
for {
con, err := l.Accept()
if err != nil {
fmt.Errorf("not able to accept listner %v", err)
}
_ = con
// serve(dataChannel)
fmt.Print("i m going to b")
go handle(con)
}
}
func handle(con net.Conn) {
fmt.Println(con)
go fetch()
}
func fetch() {
if confirmAllIp() {
f, err := os.Open("allIP.txt")
if err != nil {
fmt.Errorf("unabe to open allIP.txt %v", err)
}
scanner := bufio.NewScanner(f)
for scanner.Scan() {
v := scanner.Text()
tcpAddr, err := net.ResolveTCPAddr("tcp", v)
if err != nil {
fmt.Errorf("dont know why?? %v", err)
}
fmt.Println("i m going to die")
cmdV := exec.Command(fmt.Sprintf("curl %s:6969", tcpAddr))
time.Sleep(time.Millisecond * 9)
ret := exec.Command(fmt.Sprintf("^c"))
_ = ret
fmt.Println(cmdV)
}
}
}
func confirmAllIp() bool {
files, err := ioutil.ReadDir(".")
if err != nil {
fmt.Errorf("unable to read dir to find to allIP.txt %v", err)
}
for _, file := range files {
if file.Name() == "allIP.txt" {
return true
}
}
return false
}