mirror of
https://github.com/ehang-io/nps.git
synced 2025-07-02 04:00:42 +00:00
fix #409, support custom stun server
This commit is contained in:
parent
f6063e0d6c
commit
77c4a0cea4
@ -35,6 +35,7 @@ var (
|
|||||||
logPath = flag.String("log_path", "", "npc log path")
|
logPath = flag.String("log_path", "", "npc log path")
|
||||||
debug = flag.Bool("debug", true, "npc debug")
|
debug = flag.Bool("debug", true, "npc debug")
|
||||||
pprofAddr = flag.String("pprof", "", "PProf debug addr (ip:port)")
|
pprofAddr = flag.String("pprof", "", "PProf debug addr (ip:port)")
|
||||||
|
stunAddr = flag.String("stun_addr", "stun.stunprotocol.org:3478", "stun server address (eg:stun.stunprotocol.org:3478)")
|
||||||
)
|
)
|
||||||
|
|
||||||
const systemdScript = `[Unit]
|
const systemdScript = `[Unit]
|
||||||
@ -130,7 +131,9 @@ func main() {
|
|||||||
install.UpdateNpc()
|
install.UpdateNpc()
|
||||||
return
|
return
|
||||||
case "nat":
|
case "nat":
|
||||||
nat, host, err := stun.NewClient().Discover()
|
c := stun.NewClient()
|
||||||
|
c.SetServerAddr(*stunAddr)
|
||||||
|
nat, host, err := c.Discover()
|
||||||
if err != nil || host == nil {
|
if err != nil || host == nil {
|
||||||
logs.Error("get nat type error", err)
|
logs.Error("get nat type error", err)
|
||||||
return
|
return
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
# 增强功能
|
# 增强功能
|
||||||
## nat类型检测
|
## nat类型检测
|
||||||
```
|
```
|
||||||
./npc nat
|
./npc nat -stun_addr=stun.stunprotocol.org:3478
|
||||||
```
|
```
|
||||||
如果p2p双方都是Symmetric Nat,肯定不能成功,其他组合都有较大成功率。
|
如果p2p双方都是Symmetric Nat,肯定不能成功,其他组合都有较大成功率。`stun_addr`可以指定stun服务器地址。
|
||||||
## 状态检查
|
## 状态检查
|
||||||
```
|
```
|
||||||
./npc status -config=npc配置文件路径
|
./npc status -config=npc配置文件路径
|
||||||
|
Loading…
x
Reference in New Issue
Block a user