Answer the question
In order to leave comments, you need to log in
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
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)
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question