pion / stun Goto Github PK
View Code? Open in Web Editor NEWA Go implementation of STUN
Home Page: https://pion.ly/
License: MIT License
A Go implementation of STUN
Home Page: https://pion.ly/
License: MIT License
https://github.com/pion/stun/pull/90/checks?check_run_id=3093408033
=== RUN TestClientGC
coverage: 47.1
panic: test timed out after 10m0s
goroutine 82 [running]:
testing.(*M).startAlarm.func1()
/opt/hostedtoolcache/go/1.15.13/x64/src/testing/testing.go:1618 +0x11f
created by time.goFunc
/opt/hostedtoolcache/go/1.15.13/x64/src/time/sleep.go:167 +0x52
goroutine 1 [chan receive]:
testing.(*T).Run(0xc000001980, 0x749132, 0xc, 0x755f10, 0x1)
/opt/hostedtoolcache/go/1.15.13/x64/src/testing/testing.go:1169 +0x5f4
testing.runTests.func1(0xc000001980)
/opt/hostedtoolcache/go/1.15.13/x64/src/testing/testing.go:1439 +0xa7
testing.tRunner(0xc000001980, 0xc00007dc78)
/opt/hostedtoolcache/go/1.15.13/x64/src/testing/testing.go:1123 +0x203
testing.runTests(0xc00000e0c0, 0x8eee60, 0x73, 0x73, 0xc034d8ee4e87ed1a, 0x8bb2e65df0, 0x8f1ce0, 0x44af65)
/opt/hostedtoolcache/go/1.15.13/x64/src/testing/testing.go:1437 +0x613
testing.(*M).Run(0xc000142000, 0x0)
/opt/hostedtoolcache/go/1.15.13/x64/src/testing/testing.go:1345 +0x3b4
main.main()
_testmain.go:451 +0x357
goroutine 79 [semacquire]:
sync.runtime_Semacquire(0xc0000aa460)
/opt/hostedtoolcache/go/1.15.13/x64/src/runtime/sema.go:56 +0x45
sync.(*WaitGroup).Wait(0xc0000aa458)
/opt/hostedtoolcache/go/1.15.13/x64/src/sync/waitgroup.go:130 +0xe5
github.com/pion/stun.(*tickerCollector).Close(0xc0000aa450, 0x1, 0x9)
/home/runner/work/stun/stun/client.go:377 +0x7a
github.com/pion/stun.(*Client).Close(0xc0001206e0, 0x468959, 0x755f08)
/home/runner/work/stun/stun/client.go:396 +0x162
github.com/pion/stun.TestClientGC.func2(0xc0001206e0, 0xc000049e20, 0xc0000ca180)
/home/runner/work/stun/stun/client_test.go:575 +0x3d
github.com/pion/stun.TestClientGC(0xc0000ca180)
/home/runner/work/stun/stun/client_test.go:584 +0x546
testing.tRunner(0xc0000ca180, 0x755f10)
/opt/hostedtoolcache/go/1.15.13/x64/src/testing/testing.go:1123 +0x203
created by testing.(*T).Run
/opt/hostedtoolcache/go/1.15.13/x64/src/testing/testing.go:1168 +0x5bc
goroutine 80 [chan send]:
github.com/pion/stun.(*gcWaitAgent).Collect(0xc000010040, 0xc034d85852371d0f, 0x3cc1de5, 0x8f1ce0, 0x8f1ce0, 0x3cc1de5)
/home/runner/work/stun/stun/client_test.go:543 +0x56
github.com/pion/stun.NewClient.func1(0xc034d85852371d0f, 0x3cc1de5, 0x8f1ce0)
/home/runner/work/stun/stun/client.go:147 +0xa3
github.com/pion/stun.(*tickerCollector).Start.func1(0xc0000aa450, 0xc000067040, 0xc0000a27a0)
/home/runner/work/stun/stun/client.go:368 +0x10d
created by github.com/pion/stun.(*tickerCollector).Start
/home/runner/work/stun/stun/client.go:360 +0xb2
goroutine 81 [runnable]:
github.com/pion/stun.(*Message).Decode(0xc0001604b0, 0xc000000001, 0xe1738bf)
/home/runner/work/stun/stun/message.go:371 +0x546
github.com/pion/stun.(*Message).ReadFrom(0xc0001604b0, 0x7fe42eb44008, 0xc000012b80, 0x7fe42eb44008, 0xc000012b80, 0x0)
/home/runner/work/stun/stun/message.go:340 +0x17b
github.com/pion/stun.(*Client).readUntilClosed(0xc0001206e0)
/home/runner/work/stun/stun/client.go:327 +0x22a
created by github.com/pion/stun.NewClient
/home/runner/work/stun/stun/client.go:152 +0x647
FAIL github.com/pion/stun 600.027s
FAIL
The buffer passed to NewMessage
should be re-usable afterwards. It should not be kept around in the Message object.
Short term solution: Copy the buffer.
Full solution: Store only the parsed data, not the raw data.
I want to know how the local port of my client is being translated through NAT. How can I do this?
$ go run stun-client.go stun.l.google.com:19302
2021/01/19 00:31:22 <nil>
exit status 1
$ sudo ip -6 addr flush dev wlan0
$ go run stun-client.go stun.l.google.com:19302
xxx.xxx.xxx.xxx:52240
how test turn server
like:
{
url: 'turn:numb.viagenie.ca',
credential: 'muazkh',
username: '[email protected]'
},
{
url: 'turn:192.158.29.39:3478?transport=udp',
credential: 'JZEOEt2V3Qb0y27GRntt2u2PAYA=',
username: '28224511:1379330808'
},
{
url: 'turn:192.158.29.39:3478?transport=tcp',
credential: 'JZEOEt2V3Qb0y27GRntt2u2PAYA=',
username: '28224511:1379330808'
}
https://tools.ietf.org/html/rfc8489
Standard is already available and can be implement in this package.
As introduced by Go 1.18
I ran stun-nat-behaviour
as part of trying to set up a Tor snowflake proxy (based on these instructions: https://community.torproject.org/relay/setup/snowflake/standalone/). However it says:
INFO: 2023/05/08 05:10:32 Error: NAT discovery feature not supported by this server
Changing the stun server to stun.voipgate.com:3478
(found here: https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/-/issues/34129#note_2595581) gives results. So maybe default to that?
STUN binding transaction failed with the following public STUN servers:
STUN binding should succeed.
These servers (older implementation) returns XOR-MAPPED-ADDRESS with comprehension-required bit set, the type value being 0x8020..
Pion.stun only expects XOR-MAPPED-ADDRESS to be 0x0020, and discards the attribute.
These servers are implemented with older version of STUN, when XOR-MAPPED-ADDRESS was assigned as 'comprehension-optional', therefore, it should be optional for the client to use, but there's no way to retrieve the attribute because it is dropped, and 0x08020 is not defined. Both 0x0020 and 0x8020 must be treated as XOR-MAPPED-ADDRESS.
We should ignore the first bit of attribute field so that we can parse the field correctly regardless of the comprehension bits. Instead, we should introduce a new field to RawAttribute struct, for example, ComprehensionOptional bool
so that the application can tell whether the field was required or not. This way, we can use older version of STUN server, and also the pion would be compatible with the future version of STUN messages, meaning, the following attributes are currently optional, but it may become a requirement in the future. At that point, current pion implementation would break!
Does it support ipv6? Although our ipv6 does not have a nat, the superior route has a firewall, and the inbound is completely blocked, and because it is a 4G network, the firewall settings cannot be changed. I am wondering whether stun can be used in ipv6.
Other tools like go-stun can print the type of NAT detected by the STUN server:
> go-stun
NAT Type: Full cone NAT
External IP Family: 1
External IP: 166.111.4.100
External Port: 23009
t would be convenient if our stun did this too, and printed the result to the info log. That way people could include it in issue descriptions while debugging ICE.
Fix all the megacheck, golint and errcheck warnings so we can get the travis builds green again.
TODO:
pions/turn
and pions/webrtc
to migrate to the new API.I had the only opened TCP for Inbound rules for port 443
stun-nat-behaviour --server turn.myserver.dev:443
2020/06/07 22:45:39 Connecting to STUN server: turn.myserver.dev:443
2020/06/07 22:45:39 Local address: 0.0.0.0:50272
^C⏎
But when I enable UDP for Inbound rules for port 443.. then I see
stun-nat-behaviour --server turn.myserver.dev:443
2020/06/07 22:46:41 Connecting to STUN server: turn.myserver.dev:443
2020/06/07 22:46:41 Local address: 0.0.0.0:56357
2020/06/07 22:46:41 Received xormapped address: 103.51.74.193:56357
^C⏎
Same happed with port 5349. Do we really need to have UDP protocol open in ordered to get xormapped address?
Currently the repo is not automatically synced
Running the gstreamer-receive example from (example-webrtc-applications), with TURN enable on ARMx32 plataform return panic error,
to enable Turn:
config := webrtc.Configuration{
ICEServers: []webrtc.ICEServer{
{
URLs: []string{"turn:myserver.casainteligente.ind.br:3478"},
Username: "myuser",
Credential: "mypassword",
},
},
}
Panic Error:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x12d44]
goroutine 19 [running]:
runtime/internal/atomic.goLoad64(0x1485124, 0x6252625e, 0xbf35341d)
/usr/local/go/src/runtime/internal/atomic/atomic_arm.go:127 +0x1c
github.com/pion/stun.(*Client).Start(0x1485110, 0x1490570, 0x147b6a0, 0x340fd8, 0x147df01)
/root/go/src/github.com/pion/stun/client.go:607 +0x2e8
github.com/pion/stun.(*Client).Do(0x1485110, 0x1490570, 0x14825c0, 0x0, 0x0)
/root/go/src/github.com/pion/stun/client.go:493 +0xe8
github.com/pion/turnc.(*Client).do(0x14850a0, 0x1490570, 0x1490540, 0x1ac504, 0x362b58)
/root/go/src/github.com/pion/turnc/client.go:212 +0x80
github.com/pion/turnc.(*Client).allocate(0x14850a0, 0x1490570, 0x1490540, 0x4, 0x0, 0x0)
/root/go/src/github.com/pion/turnc/client_allocation.go:44 +0x30
github.com/pion/turnc.(*Client).Allocate(0x14850a0, 0x1482570, 0x4037c0, 0x1485110)
/root/go/src/github.com/pion/turnc/client_allocation.go:106 +0x164
github.com/pion/ice.(*Agent).gatherCandidatesRelay(0x1510120, 0x14e2378, 0x1, 0x2, 0x14e6828, 0x2)
/root/go/src/github.com/pion/ice/gather.go:300 +0x1c8
github.com/pion/ice.(*Agent).gatherCandidates(0x1510120)
/root/go/src/github.com/pion/ice/gather.go:136 +0x100
github.com/pion/ice.NewAgent(0x150bca0, 0x0, 0x0, 0x0)
/root/go/src/github.com/pion/ice/agent.go:320 +0x6ac
github.com/pion/webrtc.(*ICEGatherer).createAgent(0x1528070, 0x0, 0x0)
/root/go/src/github.com/pion/webrtc/icegatherer.go:113 +0x1bc
github.com/pion/webrtc.(*ICEGatherer).Gather(0x1528070, 0x14e8e30, 0x2800)
/root/go/src/github.com/pion/webrtc/icegatherer.go:129 +0x1c
github.com/pion/webrtc.(*PeerConnection).SetRemoteDescription(0x14f0000, 0x1, 0x1556000, 0x187c, 0x0, 0x225c, 0x0)
/root/go/src/github.com/pion/webrtc/peerconnection.go:865 +0xaac
main.gstreamerReceiveMain()
/root/go/src/github.com/pion/example-webrtc-applications/gstreamer-receive/main.go:107 +0x3a8
created by main.main
/root/go/src/github.com/pion/example-webrtc-applications/gstreamer-receive/main.go:139 +0x24
exit status 2
this error is caused at line
Line 607 in 8e0ec0d
simple comment this line works, but I would like to know a better approach to solve this problem
some docs found
https://golang.org/pkg/sync/atomic/#pkg-note-BUG
ethereum/go-ethereum#19590
golang/go#9959
There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.
Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.
go get github.com/pion/stun/tree/master/cmd/stun-nat-behaviour
installing stun-nat-behaviour
got error.
used go install github.com/pion/stun/tree/master/cmd/stun-nat-behaviour@latest
and it worked
m.Raw = make([] byte, 2048)
clinet.go readUntiClosed , the m.Raw allocate buffer 1024 is to small , some DTLS data is big ,more then 1024,will raise the data is lost by local memory,
This issue provides visibility into Renovate updates and their statuses. Learn more
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
code:
https://github.com/hktalent/dht/blob/dc96edf02e3466d8b232d2fe1a963ebf7d64bf68/stunList.go#L98
1358 @ 0x1038316 0x1031a37 0x1061d49 0x10aa832 0x10ab3da 0x10ab3c8 0x1172b69 0x117eb45 0x12e0488 0x12dd958 0x10676e1
# 0x1061d48 internal/poll.runtime_pollWait+0x88 /usr/local/Cellar/go/1.18/libexec/src/runtime/netpoll.go:302
# 0x10aa831 internal/poll.(*pollDesc).wait+0x31 /usr/local/Cellar/go/1.18/libexec/src/internal/poll/fd_poll_runtime.go:83
# 0x10ab3d9 internal/poll.(*pollDesc).waitRead+0x259 /usr/local/Cellar/go/1.18/libexec/src/internal/poll/fd_poll_runtime.go:88
# 0x10ab3c7 internal/poll.(*FD).Read+0x247 /usr/local/Cellar/go/1.18/libexec/src/internal/poll/fd_unix.go:167
# 0x1172b68 net.(*netFD).Read+0x28 /usr/local/Cellar/go/1.18/libexec/src/net/fd_posix.go:55
# 0x117eb44 net.(*conn).Read+0x44 /usr/local/Cellar/go/1.18/libexec/src/net/net.go:183
# 0x12e0487 github.com/pion/stun.(*Message).ReadFrom+0x47 /Users/51pwn/go/pkg/mod/github.com/pion/[email protected]/message.go:306
# 0x12dd957 github.com/pion/stun.(*Client).readUntilClosed+0xf7 /Users/51pwn/go/pkg/mod/github.com/pion/[email protected]/client.go:323
1357 @ 0x1038316 0x1047c32 0x12ddc48 0x10676e1
# 0x12ddc47 github.com/pion/stun.(*tickerCollector).Start.func1+0xe7 /Users/51pwn/go/pkg/mod/github.com/pion/[email protected]/client.go:359
I think the big ones are
seaduboi@38f9d359441f:~/go/src/github.com/pion/stun$ rg gortc
AUTHORS
8:The gortc project
Makefile
46: go get gortc.io/api
49: docker build -t gortc/stun .
stun.go
10:// See examples for Message for basic usage, or https://github.com/gortc/turn
message_test.go
828: NewSoftware("gortc/stun"),
849: NewSoftware("gortc/stun"),
881: NewSoftware("gortc/stun"),
appveyor.yml
11:clone_folder: c:\gopath\src\github.com\gortc\stun
README.md
111: * Explicit API backward compatibility [check](https://github.com/gortc/api), see `api` directory
113:See [TeamCity project](https://tc.gortc.io/project.html?projectId=stun&guest=1) and `e2e` directory
e2e/docker-compose.yml
15: image: gortc/coturn
e2e/test.sh
32:docker build -t gortc/tcpdump -f tcpdump.Dockerfile .
42: --name ci_stun-tcpdump --net=host gortc/tcpdump
cmd/stun-traversal/Readme.md
1:stun-traversal is a small NAT traversal proof of concept using package gortc/stun. Peer exchange is done manually using stdin.
cmd/stun-traversal/main.go
17: server = flag.String("server", fmt.Sprintf("gortc.io:3478"), "Stun server address")
When stun connection is created from existing connection, and WithNoConnClose is provided, Close hangs app.
Complete the implementation of the unpack methods on all attribute types.
Most important for debugging:
So we've decided to merge with gortc/stun and release it as stun/v2.
This is a tracking issue for that process.
Welcome to Ubuntu 20.04.1 LTS (GNU/Linux 4.19.104-microsoft-standard x86_64)
Followed README at https://github.com/pion/stun/tree/master/cmd/stun-nat-behaviour
$ sudo apt install golang-go # version 2:1.13~1ubuntu2
$ go get github.com/pion/stun/cmd/stun-nat-behaviour
$ go
Go is a tool for managing Go source code.
$ stun-nat-behaviour
stun-nat-behaviour: command not found
A usage string from stun-nat-behaviour, because "[options]" aren't expanded and explained in the README
stun-nat-behaviour couldn't be executed...seemingly because no working copy was downloaded:
$ ls -l
total 4
drwxr-xr-x 4 david david 4096 Aug 13 14:42 go
$ ls -l go
total 8
drwxr-xr-x 2 david david 4096 Aug 13 14:42 bin
drwxr-xr-x 3 david david 4096 Aug 13 14:42 src
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.