2018-05-11 06:28:31 +00:00
|
|
|
package control
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strconv"
|
|
|
|
)
|
|
|
|
|
2018-05-14 18:11:18 +00:00
|
|
|
// AttachStream invokes ATTACHSTREAM.
|
2018-05-11 06:28:31 +00:00
|
|
|
func (c *Conn) AttachStream(streamID string, circuitID string, hopNum int) error {
|
|
|
|
if circuitID == "" {
|
|
|
|
circuitID = "0"
|
|
|
|
}
|
|
|
|
cmd := "ATTACHSTREAM " + streamID + " " + circuitID
|
|
|
|
if hopNum > 0 {
|
|
|
|
cmd += " HOP=" + strconv.Itoa(hopNum)
|
|
|
|
}
|
|
|
|
return c.sendRequestIgnoreResponse(cmd)
|
|
|
|
}
|
|
|
|
|
2018-05-14 18:11:18 +00:00
|
|
|
// RedirectStream invokes REDIRECTSTREAM.
|
2018-05-11 06:28:31 +00:00
|
|
|
func (c *Conn) RedirectStream(streamID string, address string, port int) error {
|
|
|
|
cmd := "REDIRECTSTREAM " + streamID + " " + address
|
|
|
|
if port > 0 {
|
|
|
|
cmd += " " + strconv.Itoa(port)
|
|
|
|
}
|
|
|
|
return c.sendRequestIgnoreResponse(cmd)
|
|
|
|
}
|
|
|
|
|
2018-05-14 18:11:18 +00:00
|
|
|
// CloseStream invokes CLOSESTREAM.
|
2018-05-11 06:28:31 +00:00
|
|
|
func (c *Conn) CloseStream(streamID string, reason string) error {
|
|
|
|
return c.sendRequestIgnoreResponse("CLOSESTREAM %v %v", streamID, reason)
|
|
|
|
}
|