A C#(.NET Core) implementation of STUN/TURN
kadoshita / doturn Goto Github PK
View Code? Open in Web Editor NEWA C#(.NET) implementation of STUN/TURN
Home Page: http://stun.sublimer.me
License: MIT License
A C#(.NET) implementation of STUN/TURN
Home Page: http://stun.sublimer.me
License: MIT License
graph TD
Start --> STUN_MESSAGE_CHECK{Is STUN Message?};
STUN_MESSAGE_CHECK --> |No| CHANNEL_NUMBER_CHECK{Has Channel Number?};
CHANNEL_NUMBER_CHECK --> |Yes| SEND_APP_DATA_TO_PEER[Send Application Data to peer];
CHANNEL_NUMBER_CHECK --> |No| FROM_PEER_CHECK{Receive From Peer?};
FROM_PEER_CHECK --> |Yes| HAS_CHANNEL_NUMBER_CHECK{Has Channel Number?};
HAS_CHANNEL_NUMBER_CHECK --> |Yes| SEND_CHANNEL_DATA_TO_CLIENT[Send Channel Data to client];
HAS_CHANNEL_NUMBER_CHECK --> |No| SEND_DATA_INDICATE_TO_CLIENT[Send Data Indication to client];
FROM_PEER_CHECK --> |No| UNKNOWN_DATA[Unknown Data];
STUN_MESSAGE_CHECK --> |Binding Request| SEND_BIDING_RESPONSE[Send Binding Success/Error Response];
STUN_MESSAGE_CHECK --> |Allocate Request| IS_CORRECT_USER_CHECK{Is Correct User?};
IS_CORRECT_USER_CHECK --> |Yes| STORE_CLIENT_ENDPOINT[Store client endpoint];
IS_CORRECT_USER_CHECK --> |No| SEND_ALLOCATE_ERROR_RESPONSE[Send Allocate Error Respoinse];
STORE_CLIENT_ENDPOINT --> SEND_ALLOCATE_SUCCESS_RESPONSE[Send Allocate Success Response];
STUN_MESSAGE_CHECK --> |Create Permission Request| IS_CLIENT_ENDPOINT_STORED_CHECK{Is client endpoint stored?};
IS_CLIENT_ENDPOINT_STORED_CHECK --> |YES| STORE_PEER_ENDPOINT[Store peer endpoint];
IS_CLIENT_ENDPOINT_STORED_CHECK --> |No| SEND_CREATE_PERMISSION_ERROR_RESPONSE[Send Create Permission Error Response];
STORE_PEER_ENDPOINT --> SEND_CREATE_PERMISSION_SUCCESS_RESPONSE[Send Create Permission Success Response];
STUN_MESSAGE_CHECK --> |Refresh Request| LIFETIME_ZERO_CHECK{Lifetime is 0?};
LIFETIME_ZERO_CHECK --> |Yes| TERMINATE_CONNECTION[Terminate Connection];
LIFETIME_ZERO_CHECK --> |No| SEND_REFRESH_RESPONSE[Send Refresh Success/Error Response];
STUN_MESSAGE_CHECK --> |Channel Bind Request| STORE_CHANNEL_NUMBER_AND_PEER_ENDPOINT[Store Channel Number and Peer endpoint];
STORE_CHANNEL_NUMBER_AND_PEER_ENDPOINT --> SEND_CHANEL_BIND_RESPONSE[Send Channel Bind Success/Error Response];
STUN_MESSAGE_CHECK --> |Send Indicate| HAS_PERMISSION_CHECK{Has Permission?};
HAS_PERMISSION_CHECK --> |Yes| P[Send Application Data to peer];
HAS_PERMISSION_CHECK --> |No| UNKNOWN_DATA[Unknown Data];
transactionIdが 0x000000000000000000000000
のリクエストはブロックする
とりあえずパケットを受け取ってみる
RFCに定められている仕様のメモ
クラスとかいい感じに
attributeのparseをいい感じにする
RFC5766 を読んだメモ
turnutils_uclient -v -u username -w password host.docker.internal -y -s -X
0: : IPv4. Connected from: 172.19.0.2:60853
0: : IPv4. Connected from: 172.19.0.2:60853
0: : IPv4. Connected to: 192.168.65.2:3478
0: : IPv4. Connected to: 192.168.65.2:3478
0: : allocate sent
0: : allocate sent
0: : allocate response received:
0: : allocate response received:
0: : success
0: : success
0: : IPv4. Received relay addr: 127.0.0.1:49152
0: : IPv4. Received relay addr: 127.0.0.1:49152
0: : clnet_allocate: rtv=0
0: : clnet_allocate: rtv=0
0: : refresh sent
0: : refresh sent
0: : refresh response received:
0: : refresh response received:
0: : success
0: : success
0: : IPv4. Connected from: 172.19.0.2:41428
0: : IPv4. Connected from: 172.19.0.2:41428
0: : IPv4. Connected to: 192.168.65.2:3478
0: : IPv4. Connected to: 192.168.65.2:3478
0: : IPv4. Connected from: 172.19.0.2:36830
0: : IPv4. Connected from: 172.19.0.2:36830
0: : IPv4. Connected to: 192.168.65.2:3478
0: : IPv4. Connected to: 192.168.65.2:3478
0: : IPv4. Connected from: 172.19.0.2:54656
0: : IPv4. Connected from: 172.19.0.2:54656
0: : IPv4. Connected to: 192.168.65.2:3478
0: : IPv4. Connected to: 192.168.65.2:3478
0: : IPv4. Connected from: 172.19.0.2:53678
0: : IPv4. Connected from: 172.19.0.2:53678
0: : IPv4. Connected to: 192.168.65.2:3478
0: : IPv4. Connected to: 192.168.65.2:3478
0: : allocate sent
0: : allocate sent
0: : allocate response received:
0: : allocate response received:
0: : success
0: : success
0: : IPv4. Received relay addr: 127.0.0.1:49153
0: : IPv4. Received relay addr: 127.0.0.1:49153
0: : clnet_allocate: rtv=0
0: : clnet_allocate: rtv=0
0: : refresh sent
0: : refresh sent
0: : refresh response received:
0: : refresh response received:
0: : success
0: : success
0: : allocate sent
0: : allocate sent
0: : allocate response received:
0: : allocate response received:
0: : success
0: : success
0: : IPv4. Received relay addr: 127.0.0.1:49154
0: : IPv4. Received relay addr: 127.0.0.1:49154
0: : clnet_allocate: rtv=0
0: : clnet_allocate: rtv=0
0: : refresh sent
0: : refresh sent
0: : refresh response received:
0: : refresh response received:
0: : success
0: : success
0: : allocate sent
0: : allocate sent
0: : allocate response received:
0: : allocate response received:
0: : success
0: : success
0: : IPv4. Received relay addr: 127.0.0.1:49155
0: : IPv4. Received relay addr: 127.0.0.1:49155
0: : clnet_allocate: rtv=0
0: : clnet_allocate: rtv=0
0: : refresh sent
0: : refresh sent
0: : refresh response received:
0: : refresh response received:
0: : success
0: : success
0: : allocate sent
0: : allocate sent
0: : allocate response received:
0: : allocate response received:
0: : success
0: : success
0: : IPv4. Received relay addr: 127.0.0.1:49156
0: : IPv4. Received relay addr: 127.0.0.1:49156
0: : clnet_allocate: rtv=0
0: : clnet_allocate: rtv=0
0: : refresh sent
0: : refresh sent
0: : refresh response received:
0: : refresh response received:
0: : success
0: : success
0: : create perm sent: 127.0.0.1:49155
0: : create perm sent: 127.0.0.1:49155
0: : cp response received:
0: : cp response received:
0: : success
0: : success
0: : create perm sent: 127.0.0.1:49156
0: : create perm sent: 127.0.0.1:49156
0: : cp response received:
0: : cp response received:
0: : success
0: : success
0: : create perm sent: 127.0.0.1:49153
0: : create perm sent: 127.0.0.1:49153
0: : cp response received:
0: : cp response received:
0: : success
0: : success
0: : create perm sent: 127.0.0.1:49154
0: : create perm sent: 127.0.0.1:49154
0: : cp response received:
0: : cp response received:
0: : success
0: : success
0: : Total connect time is 0
0: : Total connect time is 0
1: : start_mclient: msz=4, tot_send_msgs=0, tot_recv_msgs=0, tot_send_bytes ~ 0, tot_recv_bytes ~ 0
1: : start_mclient: msz=4, tot_send_msgs=0, tot_recv_msgs=0, tot_send_bytes ~ 0, tot_recv_bytes ~ 0
2: : start_mclient: msz=4, tot_send_msgs=0, tot_recv_msgs=0, tot_send_bytes ~ 0, tot_recv_bytes ~ 0
2: : start_mclient: msz=4, tot_send_msgs=0, tot_recv_msgs=0, tot_send_bytes ~ 0, tot_recv_bytes ~ 0
3: : start_mclient: msz=4, tot_send_msgs=5, tot_recv_msgs=5, tot_send_bytes ~ 500, tot_recv_bytes ~ 500
3: : start_mclient: msz=4, tot_send_msgs=5, tot_recv_msgs=5, tot_send_bytes ~ 500, tot_recv_bytes ~ 500
4: : start_mclient: msz=4, tot_send_msgs=10, tot_recv_msgs=10, tot_send_bytes ~ 1000, tot_recv_bytes ~ 1000
4: : start_mclient: msz=4, tot_send_msgs=10, tot_recv_msgs=10, tot_send_bytes ~ 1000, tot_recv_bytes ~ 1000
5: : start_mclient: msz=4, tot_send_msgs=15, tot_recv_msgs=15, tot_send_bytes ~ 1500, tot_recv_bytes ~ 1500
5: : start_mclient: msz=4, tot_send_msgs=15, tot_recv_msgs=15, tot_send_bytes ~ 1500, tot_recv_bytes ~ 1500
5: : done, connection 0x7fc90000a010 closed.
5: : done, connection 0x7fc90000a010 closed.
5: : done, connection 0x7fc8fffe9010 closed.
5: : done, connection 0x7fc8fffe9010 closed.
5: : done, connection 0x7fc8fffc8010 closed.
5: : done, connection 0x7fc8fffc8010 closed.
5: : done, connection 0x7fc90002b010 closed.
5: : done, connection 0x7fc90002b010 closed.
5: : start_mclient: tot_send_msgs=20, tot_recv_msgs=20
5: : start_mclient: tot_send_msgs=20, tot_recv_msgs=20
5: : start_mclient: tot_send_bytes ~ 2000, tot_recv_bytes ~ 2000
5: : start_mclient: tot_send_bytes ~ 2000, tot_recv_bytes ~ 2000
5: : Total transmit time is 5
5: : Total transmit time is 5
5: : Total lost packets 0 (0.000000%), total send dropped 0 (0.000000%)
5: : Total lost packets 0 (0.000000%), total send dropped 0 (0.000000%)
5: : Average round trip delay 1.400000 ms; min = 0 ms, max = 7 ms
5: : Average round trip delay 1.400000 ms; min = 0 ms, max = 7 ms
5: : Average jitter 1.300000 ms; min = 0 ms, max = 5 ms
5: : Average jitter 1.300000 ms; min = 0 ms, max = 5 ms
使えるかもしれない
https://github.com/sprache/Sprache
いい感じの非同期処理を実装する
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.