mirror of
https://codeberg.org/cunicu/cunicu.git
synced 2025-09-26 21:01:14 +08:00
remove obsolete send-stun command
Signed-off-by: Steffen Vogel <post@steffenvogel.de>
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/pion/stun"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Creating a "connection" to STUN server.
|
||||
c, err := stun.Dial("udp", "127.0.0.1:12345")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
// Building binding request with random transaction id.
|
||||
message := stun.MustBuild(stun.TransactionID, stun.BindingRequest)
|
||||
// Sending request to STUN server, waiting for response message.
|
||||
if err := c.Do(message, func(res stun.Event) {
|
||||
if res.Error != nil {
|
||||
panic(res.Error)
|
||||
}
|
||||
// Decoding XOR-MAPPED-ADDRESS attribute from message.
|
||||
var xorAddr stun.XORMappedAddress
|
||||
if err := xorAddr.GetFrom(res.Message); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Println("your IP is", xorAddr.IP)
|
||||
}); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user