Part 1
요약·해설
CONFIG_SOCKS를 활성화하고 setsockopt 또는 MQTT helper로 SOCKS5 proxy를 지정하는 방법입니다.
CONFIG_SOCKS
SO_SOCKS5
mqtt_client_set_proxy
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
8C2BD05F863DC12AA7AD1AAD8E206C8710B92D13678E03CB629385D84A4CEFB2
.. _socks5_interface:
SOCKS5 Proxy Support
####################
.. contents::
:local:
:depth: 2
Overview
********
The SOCKS library implements SOCKS5 support, which allows Zephyr to connect
to peer devices via a network proxy.
See this
`SOCKS5 Wikipedia article <https://en.wikipedia.org/wiki/SOCKS#SOCKS5>`_
for a detailed overview of how SOCKS5 works.
For more information about the protocol itself, see
`IETF RFC1928 SOCKS Protocol Version 5 <https://tools.ietf.org/html/rfc1928>`_.
SOCKS5 API
**********
The SOCKS5 support is enabled by :kconfig:option:`CONFIG_SOCKS` Kconfig variable.
Application wanting to use the SOCKS5 must set the SOCKS5 proxy host address
by calling :c:func:`setsockopt()` like this:
.. code-block:: c
static int set_proxy(int sock, const struct sockaddr *proxy_addr,
socklen_t proxy_addrlen)
{
int ret;
ret = setsockopt(sock, SOL_SOCKET, SO_SOCKS5,
proxy_addr, proxy_addrlen);
if (ret < 0) {
return -errno;
}
return 0;
}
SOCKS5 Proxy Usage in MQTT
**************************
For MQTT client, there is :c:func:`mqtt_client_set_proxy()` API that the
application can call to setup SOCKS5 proxy. See :zephyr:code-sample:`mqtt-publisher`
sample application for usage example.
Part 3
한국어 전문 번역
개요
SOCKS library는 SOCKS5 support를 구현하여 Zephyr가 network proxy를 통해 peer device에 연결할 수 있게 합니다.
SOCKS5의 자세한 동작 개요는 SOCKS5 Wikipedia 문서를, protocol 자체의 정의는 IETF RFC 1928 SOCKS Protocol Version 5를 참고하십시오.
SOCKS5 API
CONFIG_SOCKS Kconfig variable로 SOCKS5 support를 활성화합니다. SOCKS5를 사용하려는 application은 다음처럼 setsockopt()를 호출해 SOCKS5 proxy host address를 설정해야 합니다.
static int set_proxy(int sock, const struct sockaddr *proxy_addr,
socklen_t proxy_addrlen)
{
int ret;
ret = setsockopt(sock, SOL_SOCKET, SO_SOCKS5,
proxy_addr, proxy_addrlen);
if (ret < 0) {
return -errno;
}
return 0;
}SOL_SOCKET level에서 SO_SOCKS5 option에 proxy address와 길이를 전달합니다. 실패하면 errno를 음수로 반환하고 성공하면 0을 반환합니다.
MQTT에서 SOCKS5 Proxy 사용
MQTT client에는 application이 SOCKS5 proxy를 설정할 수 있는 mqtt_client_set_proxy() API가 있습니다. 사용 예는 MQTT Publisher sample application을 참고하십시오.
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.