mirror of
https://github.com/xmdhs/natupnp.git
synced 2025-10-29 09:32:31 +08:00
fix
This commit is contained in:
31
main.go
31
main.go
@@ -50,21 +50,24 @@ func main() {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if target != "" {
|
||||
err := natmap.Forward(ctx, uint16(portu), target, func(s string) {
|
||||
log.Println(s)
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
if test {
|
||||
testServer(port)
|
||||
}
|
||||
|
||||
m, s, err := natmap.NatMap(ctx, "stun.sipnet.com:3478", localAddr, uint16(portu), func(s string) {
|
||||
m, s, err := natmap.NatMap(ctx, stun, localAddr, uint16(portu), func(s string) {
|
||||
log.Println(s)
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if test {
|
||||
go testServer(port)
|
||||
}
|
||||
if target != "" {
|
||||
go natmap.Forward(ctx, uint16(portu), target, func(s string) {
|
||||
log.Println(s)
|
||||
})
|
||||
}
|
||||
|
||||
defer m.Close()
|
||||
fmt.Println(s)
|
||||
@@ -84,8 +87,10 @@ func testServer(port string) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
err = s.Serve(l)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
go func() {
|
||||
err = s.Serve(l)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user