-
Notifications
You must be signed in to change notification settings - Fork 481
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v0.4.0
- Loading branch information
Showing
37 changed files
with
516 additions
and
602 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,4 +33,9 @@ | |
|
||
# v0.3.0 | ||
|
||
1. 新增shell隧道的支持 | ||
1. 新增shell隧道的支持 | ||
|
||
# v0.4.0 | ||
|
||
1. 配置文件支持include语法 | ||
2. 通用的握手方式,支持tcp和shell |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package pool | ||
|
||
import ( | ||
"natpass/code/client/global" | ||
"natpass/code/network" | ||
"time" | ||
) | ||
|
||
// SendConnectReq send connect request message | ||
func (conn *Conn) SendConnectReq(id string, cfg global.Tunnel) { | ||
var msg network.Msg | ||
msg.To = cfg.Target | ||
msg.XType = network.Msg_connect_req | ||
msg.LinkId = id | ||
switch cfg.Type { | ||
case "tcp": | ||
msg.Payload = &network.Msg_Creq{ | ||
Creq: &network.ConnectRequest{ | ||
Name: cfg.Name, | ||
XType: network.ConnectRequest_tcp, | ||
Payload: &network.ConnectRequest_Caddr{ | ||
Caddr: &network.ConnectAddr{ | ||
Addr: cfg.RemoteAddr, | ||
Port: uint32(cfg.RemotePort), | ||
}, | ||
}, | ||
}, | ||
} | ||
case "udp": | ||
case "shell": | ||
msg.Payload = &network.Msg_Creq{ | ||
Creq: &network.ConnectRequest{ | ||
Name: cfg.Name, | ||
XType: network.ConnectRequest_shell, | ||
Payload: &network.ConnectRequest_Cshell{ | ||
Cshell: &network.ConnectShell{ | ||
Exec: cfg.Exec, | ||
Env: cfg.Env, | ||
}, | ||
}, | ||
}, | ||
} | ||
} | ||
select { | ||
case conn.write <- &msg: | ||
case <-time.After(conn.parent.cfg.WriteTimeout): | ||
} | ||
} | ||
|
||
// SendConnectError send connect error response message | ||
func (conn *Conn) SendConnectError(to string, toIdx uint32, id, info string) { | ||
var msg network.Msg | ||
msg.To = to | ||
msg.ToIdx = toIdx | ||
msg.XType = network.Msg_connect_rep | ||
msg.LinkId = id | ||
msg.Payload = &network.Msg_Crep{ | ||
Crep: &network.ConnectResponse{ | ||
Ok: false, | ||
Msg: info, | ||
}, | ||
} | ||
select { | ||
case conn.write <- &msg: | ||
case <-time.After(conn.parent.cfg.WriteTimeout): | ||
} | ||
} | ||
|
||
// SendConnectOK send connect success response message | ||
func (conn *Conn) SendConnectOK(to string, toIdx uint32, id string) { | ||
var msg network.Msg | ||
msg.To = to | ||
msg.ToIdx = toIdx | ||
msg.XType = network.Msg_connect_rep | ||
msg.LinkId = id | ||
msg.Payload = &network.Msg_Crep{ | ||
Crep: &network.ConnectResponse{ | ||
Ok: true, | ||
}, | ||
} | ||
select { | ||
case conn.write <- &msg: | ||
case <-time.After(conn.parent.cfg.WriteTimeout): | ||
} | ||
} | ||
|
||
// SendDisconnect send disconnect message | ||
func (conn *Conn) SendDisconnect(to string, toIdx uint32, id string) { | ||
var msg network.Msg | ||
msg.To = to | ||
msg.ToIdx = toIdx | ||
msg.XType = network.Msg_disconnect | ||
msg.LinkId = id | ||
select { | ||
case conn.write <- &msg: | ||
case <-time.After(conn.parent.cfg.WriteTimeout): | ||
} | ||
} |
Oops, something went wrong.