Esempio n. 1
0
// Attempt to hijack session previously running bot
func (irc *IrcCon) HijackSession() bool {
	unaddr, err := net.ResolveUnixAddr("unix", irc.unixastr)
	if err != nil {
		irc.Log(LWarning, "could not resolve unix socket")
		return false
	}

	con, err := net.DialUnix("unix", nil, unaddr)
	if err != nil {
		fmt.Println("Couldnt restablish connection, no prior bot.")
		fmt.Println(err)
		return false
	}

	ncon, err := sendfd.RecvFD(con)
	if err != nil {
		panic(err)
	}

	netcon, err := net.FileConn(ncon)
	if err != nil {
		panic(err)
	}

	irc.reconnect = true
	irc.con = netcon
	return true
}
Esempio n. 2
0
// Attempt to hijack session previously running bot
func (irc *Bot) hijackSession() bool {
	unaddr, err := net.ResolveUnixAddr("unix", irc.unixastr) // The only way to get an error here is if the first parameter is not one of "unix", "unixgram" or "unixpacket". That will never happen.
	if err != nil {
		panic(err)
	}
	con, err := net.DialUnix("unix", nil, unaddr)
	if err != nil {
		irc.Info("Couldnt restablish connection, no prior bot.", "err", err)
		return false
	}
	ncon, err := sendfd.RecvFD(con)
	if err != nil {
		panic(err)
	}
	netcon, err := net.FileConn(ncon)
	if err != nil {
		panic(err)
	}
	irc.reconnecting = true
	irc.con = netcon
	return true
}