mirror of
https://github.com/lwch/natpass.git
synced 2024-04-21 12:41:54 +00:00
42 lines
774 B
Go
42 lines
774 B
Go
package pool
|
|
|
|
import (
|
|
"natpass/code/client/global"
|
|
"natpass/code/network"
|
|
)
|
|
|
|
// SendConnect send connect request message
|
|
func (p *Pool) SendConnect(id string, t global.Tunnel) {
|
|
tp := network.ConnectRequest_tcp
|
|
if t.Type != "tcp" {
|
|
tp = network.ConnectRequest_udp
|
|
}
|
|
p.writeConnect <- connectData{
|
|
to: t.Target,
|
|
id: id,
|
|
name: t.Name,
|
|
tp: tp,
|
|
addr: t.RemoteAddr,
|
|
port: t.RemotePort,
|
|
}
|
|
}
|
|
|
|
// SendDisconnect send disconnect message
|
|
func (p *Pool) SendDisconnect(id, to string) {
|
|
p.writeDisconnect <- disconnectData{
|
|
to: to,
|
|
id: id,
|
|
}
|
|
}
|
|
|
|
// SendData send forward data
|
|
func (p *Pool) SendData(id, to string, data []byte) {
|
|
dup := make([]byte, len(data))
|
|
copy(dup, data)
|
|
p.writeForward <- forwardData{
|
|
to: to,
|
|
id: id,
|
|
data: dup,
|
|
}
|
|
}
|