V
V
Vladimir Grabko2016-04-21 17:18:22
go
Vladimir Grabko, 2016-04-21 17:18:22

How to send data over nat?

Hello. I used Stun Server to bypass nat. Now I receive from him

Symetric NAT
host.Family = 1
host.IP        = 46.63.122.27
host.Port     = 9287

I can't figure out how to catch the data that the server will send me at 46.63.122.27:9287 thanks in advance.
Here is the code
package main

import (
  "botnet/ethernet/stun"
  "fmt"
  "net/http"
)

func requestHandler(w http.ResponseWriter, r *http.Request) {
  fmt.Fprintf(w, "Hello, world")
}

func main() {
  nat, host, err := stun.NewClient().Discover()
  if err != nil {
    fmt.Println(err)
  }
  switch nat {
  case stun.NAT_ERROR:
    fmt.Println("Test failed")
  case stun.NAT_UNKNOWN:
    fmt.Println("Unexpected response from the STUN server")
  case stun.NAT_BLOCKED:
    fmt.Println("UDP is blocked")
  case stun.NAT_FULL:
    fmt.Println("Full cone NAT")
  case stun.NAT_SYMETRIC:
    fmt.Println("Symetric NAT")
  case stun.NAT_RESTRICTED:
    fmt.Println("Restricted NAT")
  case stun.NAT_PORT_RESTRICTED:
    fmt.Println("Port restricted NAT")
  case stun.NAT_NONE:
    fmt.Println("Not behind a NAT")
  case stun.NAT_SYMETRIC_UDP_FIREWALL:
    fmt.Println("Symetric UDP firewall")
  }
  if host != nil {
    fmt.Println(host.Family())
    fmt.Println(host.IP())
    fmt.Println(host.Port())
  }

  http.HandleFunc("/", requestHandler)
  http.ListenAndServe(fmt.Sprintf(":%v", host.IP()), nil)
}

I recognize the port and create a web service on this port. I'm trying to go to ip:port, it doesn't work..

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir, 2016-04-21
@rostel

this may only work for UPD

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question