-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #298 from cnlh/dev
Dev
- Loading branch information
Showing
15 changed files
with
350 additions
and
69 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 |
---|---|---|
|
@@ -247,23 +247,22 @@ nps是一款轻量级、高性能、功能强大的**内网穿透**代理服务 | |
**适用范围:** 大流量传输场景,流量不经过公网服务器,但是由于p2p穿透和nat类型关系较大,不保证100%成功,支持大部分nat类型。[nat类型检测](#nat类型检测) | ||
|
||
**假设场景:** | ||
内网1机器ip为10.1.50.2 内网2机器2 ip为10.2.50.2 | ||
|
||
想通过访问内网1机器1的2000端口---->访问到内网2机器3 10.2.50.3的22端口 | ||
想通过访问使用端机器(访问端,也就是本机)的2000端口---->访问到内网机器 10.2.50.2的22端口 | ||
|
||
**使用步骤** | ||
- 在`nps.conf`中设置`p2p_ip`(nps服务器ip)和`p2p_port`(nps服务器udp端口) | ||
- 在刚才刚才创建的客户端中添加一条p2p代理,并设置唯一密钥p2pssh | ||
- 在机器1执行命令 | ||
- 在使用端机器(本机)执行命令 | ||
|
||
``` | ||
./npc -server=1.1.1.1:8284 -vkey=123 -password=p2pssh -target=10.2.50.3:22 | ||
./npc -server=1.1.1.1:8284 -vkey=123 -password=p2pssh -target=10.2.50.2:22 | ||
``` | ||
如需指定本地端口可加参数`-local_port=xx`,默认为2000 | ||
|
||
**注意:** password为web管理上添加的唯一密钥,具体命令可查看web管理上的命令提示 | ||
|
||
假设机器3用户名为root,现在在机器1上执行`ssh -p 2000 [email protected]`即可访问机器2的ssh | ||
假设内网机器为10.2.50.2的ssh用户名为root,现在在本机上执行`ssh -p 2000 [email protected]`即可访问机器2的ssh,如果是网站在浏览器访问127.0.0.1:2000端口即可。 | ||
|
||
|
||
|
||
|
@@ -1040,6 +1039,13 @@ POST /auth/getauthkey | |
|
||
## 捐助 | ||
如果您觉得nps对你有帮助,欢迎给予我们一定捐助,也是帮助nps更好的发展。 | ||
## 致谢 | ||
Thanks [jetbrains](https://www.jetbrains.com/?from=nps) for providing development tools for nps | ||
|
||
<html> | ||
<img src="https://ftp.bmp.ovh/imgs/2019/12/6435398b0c7402b1.png" width="300" align=center /> | ||
</html> | ||
|
||
|
||
### 支付宝 | ||
![image](https://github.com/cnlh/nps/blob/master/image/donation_zfb.png?raw=true) | ||
|
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,48 @@ | ||
package common | ||
|
||
import ( | ||
"github.com/astaxie/beego/logs" | ||
"time" | ||
) | ||
|
||
const MaxMsgLen = 5000 | ||
|
||
var logMsgs string | ||
|
||
func init() { | ||
logs.Register("store", func() logs.Logger { | ||
return new(StoreMsg) | ||
}) | ||
} | ||
|
||
func GetLogMsg() string { | ||
return logMsgs | ||
} | ||
|
||
type StoreMsg struct { | ||
} | ||
|
||
func (lg *StoreMsg) Init(config string) error { | ||
return nil | ||
} | ||
|
||
func (lg *StoreMsg) WriteMsg(when time.Time, msg string, level int) error { | ||
m := when.Format("2006-01-02 15:04:05") + " " + msg + "\r\n" | ||
if len(logMsgs) > MaxMsgLen { | ||
start := MaxMsgLen - len(m) | ||
if start <= 0 { | ||
start = MaxMsgLen | ||
} | ||
logMsgs = logMsgs[start:] | ||
} | ||
logMsgs += m | ||
return nil | ||
} | ||
|
||
func (lg *StoreMsg) Destroy() { | ||
return | ||
} | ||
|
||
func (lg *StoreMsg) Flush() { | ||
return | ||
} |
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
Oops, something went wrong.