Codync
๋ฌด๋ฃ ์คํ์์ค 1:1 ๋์, Grok Bot๊ณผ Muse ๋์
๐ต STUN for Java
๊ฐ๋ฐ ๋๊ตฌGitHub @umjammer์จ๋ผ์ธ์ด์์ ๋ฏธํ์ธ
์จ ๋ณด์ จ์ด์? ํ ๋ฒ๋ง ๋๋ฌ ์ฃผ์ธ์. ๋ก๊ทธ์ธ์ ํ์ ์์ด์.
์ ์ฅ์ ์ ๋ณด๋ ์์ง ์์งํ์ง ์์์ต๋๋ค.
์์ง ๊ฐ์ง๋ ์ ๋ฐ์ดํธ๊ฐ ์์ต๋๋ค. GitHub ๋ฆด๋ฆฌ์ค๊ฐ ๋์ค๋ฉด ์ฌ๊ธฐ์ ๋ณด์ ๋๋ค.
๋ก๊ทธ์ธ ์ํ๋ฅผ ํ์ธํ๋ ์ค์ ๋๋ค.
๋๊ธ์ ๋ถ๋ฌ์ค๋ ์ค์ ๋๋ค.
๋ฉ์ด์ปค๊ฐ ์ด ์๊ฐ๋ ์์ ํ ์ค์ด ์ ๋ถ์ ๋๋ค. ๋ ์์ธํ ๋ด์ฉ์ ์ ์ฅ์ README์์ ์ฝ์ ์ ์์ต๋๋ค. ์ ์ฅ์ README โ
README ์ ์ฒด๋ฅผ ๋ถ๋ฌ์ค๋ ์ค์ ๋๋ค.
README ์ ๋ฌธ ๋ณด๊ธฐ โSTUN for Java
STUN (RFC 8489 / 5389, Binding over UDP) client, server and classic NAT type discovery (RFC 3489 algorithm with RFC 5780 attributes).
try (DatagramSocket socket = new DatagramSocket()) {
StunClient client = new StunClient(socket);
// the reflexive address of this socket
InetSocketAddress mapped = client.bind(new InetSocketAddress("stun.example.com", 3478)).mappedAddress();
// OPEN_INTERNET, FULL_CONE, RESTRICTED_CONE, PORT_RESTRICTED_CONE, SYMMETRIC, SYMMETRIC_FIREWALL, UDP_BLOCKED
NatType type = client.discoverNatType(new InetSocketAddress("stun.example.com", 3478));
}
// primary 192.0.2.1:3478, alternate port 3479, alternate ip 192.0.2.2 (for CHANGE-REQUEST)
StunServer server = new StunServer(new InetSocketAddress("192.0.2.1", 3478), 3479, InetAddress.getByName("192.0.2.2")).start();
A server without an alternate ip answers "change ip" with 420, or delegates it to another server
by StunServer#setChangeIpRelay (the overlay network nodes relay to each other this way).
StunMessageTest ... RFC 5769 test vectorsNatTypeDiscoveryTest ... discovery against simulated NATs/firewalls (RFC 4787 mapping/filtering behaviors), uses 127.0.0.2IptablesFirewallTest ... discovery behind real iptables firewalls and SNAT, needs root
sudo mvn test -Dtest=IptablesFirewallTest -Dstun.iptables=true
image designed by @umjammer, drawn by nano banana