Skip to content

Commit

Permalink
event-hook: connect: Support local hole port
Browse files Browse the repository at this point in the history
  • Loading branch information
hzyitc committed Nov 17, 2021
1 parent 81220c7 commit 0105f5e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,10 @@ func tcp() {
}
defer mode.Close()

_, port, _ := net.SplitHostPort(mode.LocalHoleAddr().String())
for {
func() {
runHook("connecting", "", "", "")
runHook("connecting", "", string(port), "")

protocol, err := TCPProtocol.NewMnhv1(mode, server, id)
if err != nil {
Expand All @@ -175,7 +176,6 @@ func tcp() {

log.Info("\n\nNow you can use " + protocol.NATedAddr().String() + " to access your service")

_, port, _ := net.SplitHostPort(protocol.LocalHoleAddr().String())
addr := protocol.NATedAddr().String()
runHook("success", "", port, addr)
defer runHook("disconnected", "", port, addr)
Expand Down Expand Up @@ -235,9 +235,10 @@ func udp() {
}
defer mode.Close()

_, port, _ := net.SplitHostPort(mode.LocalHoleAddr().String())
for {
func() {
runHook("connecting", "", "", "")
runHook("connecting", "", string(port), "")

protocol, err := UDPProtocol.NewMnhv1(mode, server, id)
if err != nil {
Expand All @@ -254,7 +255,6 @@ func udp() {

log.Info("\n\nNow you can use " + protocol.NATedAddr().String() + " to access your service")

_, port, _ := net.SplitHostPort(protocol.LocalHoleAddr().String())
addr := protocol.NATedAddr().String()
runHook("success", "", port, addr)
defer runHook("disconnected", "", port, addr)
Expand Down

0 comments on commit 0105f5e

Please sign in to comment.