File: cmd_stream.go

package info (click to toggle)
golang-github-cretz-bine 0.2.0%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bookworm-backports, sid, trixie
  • size: 652 kB
  • sloc: makefile: 3
file content (31 lines) | stat: -rw-r--r-- 813 bytes parent folder | download
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
package control

import (
	"strconv"
)

// AttachStream invokes ATTACHSTREAM.
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)
}

// RedirectStream invokes REDIRECTSTREAM.
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)
}

// CloseStream invokes CLOSESTREAM.
func (c *Conn) CloseStream(streamID string, reason string) error {
	return c.sendRequestIgnoreResponse("CLOSESTREAM %v %v", streamID, reason)
}