|
|
@ -224,7 +224,7 @@ func tcpupload(file, prefix string, mytcp net.Conn) error {
|
|
|
|
time.Sleep(time.Millisecond * 100)
|
|
|
|
time.Sleep(time.Millisecond * 100)
|
|
|
|
sakura++
|
|
|
|
sakura++
|
|
|
|
if sakura > 50 {
|
|
|
|
if sakura > 50 {
|
|
|
|
mytcp.Write([]byte{1, 9, 9, 6, 1, 1, 2, 7, 6, 6, 6, 1, 1, 2, 7})
|
|
|
|
mytcp.Write([]byte{1, 9, 9, 6, 1, 1, 2, 7})
|
|
|
|
time.Sleep(time.Millisecond * 100)
|
|
|
|
time.Sleep(time.Millisecond * 100)
|
|
|
|
mytcp.Write([]byte("victorique&" + stat.Name() + "&" + prefix))
|
|
|
|
mytcp.Write([]byte("victorique&" + stat.Name() + "&" + prefix))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -237,9 +237,9 @@ func tcpupload(file, prefix string, mytcp net.Conn) error {
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
if err == io.EOF {
|
|
|
|
if err == io.EOF {
|
|
|
|
err = nil
|
|
|
|
err = nil
|
|
|
|
|
|
|
|
mytcp.Write([]byte{1, 9, 9, 6, 1, 1, 2, 7})
|
|
|
|
for !backsck {
|
|
|
|
for !backsck {
|
|
|
|
time.Sleep(time.Millisecond * 150)
|
|
|
|
time.Sleep(time.Millisecond * 150)
|
|
|
|
mytcp.Write([]byte{1, 9, 9, 6, 1, 1, 2, 7, 6, 6, 6, 1, 1, 2, 7})
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
backsck = false
|
|
|
|
backsck = false
|
|
|
|
break
|
|
|
|
break
|
|
|
@ -347,7 +347,7 @@ var tcprecvcmd = &cobra.Command{
|
|
|
|
defer conns.Close()
|
|
|
|
defer conns.Close()
|
|
|
|
var sum int
|
|
|
|
var sum int
|
|
|
|
for {
|
|
|
|
for {
|
|
|
|
buf := make([]byte, 524288)
|
|
|
|
buf := make([]byte, 393216)
|
|
|
|
n, err := conns.Read(buf)
|
|
|
|
n, err := conns.Read(buf)
|
|
|
|
|
|
|
|
|
|
|
|
if !canrecv {
|
|
|
|
if !canrecv {
|
|
|
@ -364,10 +364,13 @@ var tcprecvcmd = &cobra.Command{
|
|
|
|
canrecv = true
|
|
|
|
canrecv = true
|
|
|
|
name = str[1]
|
|
|
|
name = str[1]
|
|
|
|
prefix := str[2]
|
|
|
|
prefix := str[2]
|
|
|
|
|
|
|
|
if runtime.GOOS != "windows" {
|
|
|
|
|
|
|
|
prefix = strings.Replace(prefix, "\\", "/", -1)
|
|
|
|
|
|
|
|
}
|
|
|
|
if prefix == "" {
|
|
|
|
if prefix == "" {
|
|
|
|
fpdst, err = os.Create("./" + name)
|
|
|
|
fpdst, err = os.Create("./" + name)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
fpdst, err = os.Create(prefix + "/" + name)
|
|
|
|
fpdst, err = os.Create(prefix + name)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
fmt.Println(err)
|
|
|
@ -381,18 +384,19 @@ var tcprecvcmd = &cobra.Command{
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if n < 524288 && buf[n-1] == byte(7) {
|
|
|
|
if buf[n-1] == byte(7) && buf[n-2] == byte(2) && buf[n-3] == byte(1) {
|
|
|
|
ok := func() bool {
|
|
|
|
ok := func() bool {
|
|
|
|
for k, v := range []byte{1, 9, 9, 6, 1, 1, 2, 7, 6, 6, 6, 1, 1, 2, 7} {
|
|
|
|
for k, v := range []byte{1, 9, 9, 6, 1, 1, 2, 7} {
|
|
|
|
if buf[n-15+k] != v {
|
|
|
|
if buf[n-8+k] != v {
|
|
|
|
return false
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
return true
|
|
|
|
}()
|
|
|
|
}()
|
|
|
|
if ok {
|
|
|
|
if ok {
|
|
|
|
if n > 15 {
|
|
|
|
if n > 8 {
|
|
|
|
fpdst.Write(buf[0 : n-15])
|
|
|
|
fpdst.Write(buf[0 : n-8])
|
|
|
|
|
|
|
|
sum += n - 8
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fmt.Printf("已写入:%d 字节\n", sum)
|
|
|
|
fmt.Printf("已写入:%d 字节\n", sum)
|
|
|
|
fmt.Println(name + "接收成功\n")
|
|
|
|
fmt.Println(name + "接收成功\n")
|
|
|
|