This commit is contained in:
poiuty 2023-05-13 00:18:52 +03:00
parent db66cde2fe
commit 89f19d68cc
2 changed files with 38 additions and 11 deletions

View file

@ -3,19 +3,38 @@ package main
import (
"net"
"time"
"fmt"
)
var echoSocket = make(chan []byte)
func startSocket() {
var(
err error
conn net.Conn
)
for {
select {
case b := <-echoSocket:
conn, err := net.Dial("unix", "/tmp/echo.sock")
if err == nil {
conn.Write(b)
conn.Close()
if conn == nil {
conn, err = net.Dial("unix", "/tmp/echo.sock")
if err != nil {
fmt.Println(err.Error())
continue
}
}
if conn != nil {
if _, err = conn.Write(b); err != nil {
fmt.Println(err.Error())
conn.Close()
conn = nil
}
}
}
}
}
@ -24,8 +43,8 @@ func main() {
go startSocket()
for {
echoSocket <- []byte(`{"chanel":"stripchat","room":"naughtyobsessions","donator":"tbone6893","amount":333}`)
echoSocket <- []byte(`{"chanel":"stripchat","index":28}`)
echoSocket <- []byte(`{"chanel":"chaturbate","room":"naughtyobsessions","donator":"tbone6893","amount":333}`)
echoSocket <- []byte(`{"chanel":"chaturbate","index":28}`)
time.Sleep(1e9)
}
}