This commit is contained in:
InsanusMokrassar 2023-10-11 15:04:23 +00:00
parent a7e133579b
commit 354529728e
4 changed files with 91 additions and 78 deletions

File diff suppressed because one or more lines are too long

View File

@ -2,187 +2,187 @@
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://docs.inmo.dev/index.html</loc>
<lastmod>2023-10-06</lastmod>
<lastmod>2023-10-11</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://docs.inmo.dev/krontab/index.html</loc>
<lastmod>2023-10-06</lastmod>
<lastmod>2023-10-11</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://docs.inmo.dev/krontab/describing/krontabscheduler.html</loc>
<lastmod>2023-10-06</lastmod>
<lastmod>2023-10-11</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://docs.inmo.dev/krontab/describing/string-format.html</loc>
<lastmod>2023-10-06</lastmod>
<lastmod>2023-10-11</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://docs.inmo.dev/krontab/introduction/faq.html</loc>
<lastmod>2023-10-06</lastmod>
<lastmod>2023-10-11</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://docs.inmo.dev/krontab/introduction/how-to-use.html</loc>
<lastmod>2023-10-06</lastmod>
<lastmod>2023-10-11</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://docs.inmo.dev/krontab/introduction/including-in-project.html</loc>
<lastmod>2023-10-06</lastmod>
<lastmod>2023-10-11</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://docs.inmo.dev/kslog/index.html</loc>
<lastmod>2023-10-06</lastmod>
<lastmod>2023-10-11</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://docs.inmo.dev/kslog/logging.html</loc>
<lastmod>2023-10-06</lastmod>
<lastmod>2023-10-11</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://docs.inmo.dev/kslog/setup.html</loc>
<lastmod>2023-10-06</lastmod>
<lastmod>2023-10-11</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://docs.inmo.dev/micro_utils/index.html</loc>
<lastmod>2023-10-06</lastmod>
<lastmod>2023-10-11</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://docs.inmo.dev/navigation/index.html</loc>
<lastmod>2023-10-06</lastmod>
<lastmod>2023-10-11</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://docs.inmo.dev/plagubot/index.html</loc>
<lastmod>2023-10-06</lastmod>
<lastmod>2023-10-11</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://docs.inmo.dev/plagubot/opportunities_out_of_the_box.html</loc>
<lastmod>2023-10-06</lastmod>
<lastmod>2023-10-11</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://docs.inmo.dev/tgbotapi/index.html</loc>
<lastmod>2023-10-06</lastmod>
<lastmod>2023-10-11</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://docs.inmo.dev/tgbotapi/faq.html</loc>
<lastmod>2023-10-06</lastmod>
<lastmod>2023-10-11</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://docs.inmo.dev/tgbotapi/dsls/keyboards.html</loc>
<lastmod>2023-10-06</lastmod>
<lastmod>2023-10-11</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://docs.inmo.dev/tgbotapi/dsls/live-location.html</loc>
<lastmod>2023-10-06</lastmod>
<lastmod>2023-10-11</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://docs.inmo.dev/tgbotapi/dsls/text.html</loc>
<lastmod>2023-10-06</lastmod>
<lastmod>2023-10-11</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://docs.inmo.dev/tgbotapi/guides/keyboards.html</loc>
<lastmod>2023-10-06</lastmod>
<lastmod>2023-10-11</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://docs.inmo.dev/tgbotapi/introduction/before-any-bot-project.html</loc>
<lastmod>2023-10-06</lastmod>
<lastmod>2023-10-11</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://docs.inmo.dev/tgbotapi/introduction/first-bot.html</loc>
<lastmod>2023-10-06</lastmod>
<lastmod>2023-10-11</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://docs.inmo.dev/tgbotapi/introduction/including-in-your-project.html</loc>
<lastmod>2023-10-06</lastmod>
<lastmod>2023-10-11</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://docs.inmo.dev/tgbotapi/introduction/proxy-setup.html</loc>
<lastmod>2023-10-06</lastmod>
<lastmod>2023-10-11</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://docs.inmo.dev/tgbotapi/logic/api-extensions.html</loc>
<lastmod>2023-10-06</lastmod>
<lastmod>2023-10-11</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://docs.inmo.dev/tgbotapi/logic/behaviour-builder-with-fsm.html</loc>
<lastmod>2023-10-06</lastmod>
<lastmod>2023-10-11</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://docs.inmo.dev/tgbotapi/logic/behaviour-builder.html</loc>
<lastmod>2023-10-06</lastmod>
<lastmod>2023-10-11</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://docs.inmo.dev/tgbotapi/logic/exceptions-handling.html</loc>
<lastmod>2023-10-06</lastmod>
<lastmod>2023-10-11</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://docs.inmo.dev/tgbotapi/logic/files-handling.html</loc>
<lastmod>2023-10-06</lastmod>
<lastmod>2023-10-11</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://docs.inmo.dev/tgbotapi/logic/low-level-work-with-bots.html</loc>
<lastmod>2023-10-06</lastmod>
<lastmod>2023-10-11</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://docs.inmo.dev/tgbotapi/logic/media-groups.html</loc>
<lastmod>2023-10-06</lastmod>
<lastmod>2023-10-11</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://docs.inmo.dev/tgbotapi/logic/types-conversations.html</loc>
<lastmod>2023-10-06</lastmod>
<lastmod>2023-10-11</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://docs.inmo.dev/tgbotapi/logic/updates-with-flows.html</loc>
<lastmod>2023-10-06</lastmod>
<lastmod>2023-10-11</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://docs.inmo.dev/tgbotapi/updates/heroku.html</loc>
<lastmod>2023-10-06</lastmod>
<lastmod>2023-10-11</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://docs.inmo.dev/tgbotapi/updates/long-polling.html</loc>
<lastmod>2023-10-06</lastmod>
<lastmod>2023-10-11</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://docs.inmo.dev/tgbotapi/updates/updates-filters.html</loc>
<lastmod>2023-10-06</lastmod>
<lastmod>2023-10-11</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://docs.inmo.dev/tgbotapi/updates/webhooks.html</loc>
<lastmod>2023-10-06</lastmod>
<lastmod>2023-10-11</lastmod>
<changefreq>daily</changefreq>
</url>
</urlset>

Binary file not shown.

View File

@ -2047,26 +2047,40 @@
<h3 id="using-ktor-client-built-in-proxy">Using Ktor Client built-in proxy<a class="headerlink" href="#using-ktor-client-built-in-proxy" title="Permanent link">&para;</a></h3>
<p>First of all, you will need to use one more library:</p>
<p><strong>build.gradle</strong>:</p>
<div class="language-groovy highlight"><pre><span></span><code><span id="__span-1-1"><a id="__codelineno-1-1" name="__codelineno-1-1" href="#__codelineno-1-1"></a><span class="n">implementation</span><span class="w"> </span><span class="s2">&quot;io.ktor:ktor-client-okhttp:2.0.1&quot;</span>
<div class="language-groovy highlight"><pre><span></span><code><span id="__span-1-1"><a id="__codelineno-1-1" name="__codelineno-1-1" href="#__codelineno-1-1"></a><span class="n">implementation</span><span class="w"> </span><span class="s2">&quot;io.ktor:ktor-client-okhttp:2.3.5&quot;</span>
</span></code></pre></div>
<div class="admonition note">
<p class="admonition-title">Dependency note</p>
<p>
In the snippet above was used version <code>2.0.1</code> which is actual for <code>TelegramBotAPI</code> at the moment of filling this documentation (<code>May 22 2022</code>, <code>TelegramBotAPI</code> version <code>2.0.0</code>) and you can update version of this dependency in case if it is outdated.</p>
In the snippet above was used version <code>2.3.5</code> which is actual for <code>TelegramBotAPI</code> at the moment of filling this documentation (<code>october 11 2023</code>, <code>TelegramBotAPI</code> version <code>9.2.2</code>) and you can update version of this dependency in case if it is outdated.</p>
</div>
<p>For configuring proxy for your bot inside your program, you can use next snippet:</p>
<div class="language-kotlin highlight"><pre><span></span><code><span id="__span-2-1"><a id="__codelineno-2-1" name="__codelineno-2-1" href="#__codelineno-2-1"></a><span class="kd">val</span><span class="w"> </span><span class="nv">botToken</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;HERE MUST BE YOUR TOKEN&quot;</span>
</span><span id="__span-2-2"><a id="__codelineno-2-2" name="__codelineno-2-2" href="#__codelineno-2-2"></a><span class="kd">val</span><span class="w"> </span><span class="nv">bot</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">telegramBot</span><span class="p">(</span><span class="n">botToken</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
</span><span id="__span-2-3"><a id="__codelineno-2-3" name="__codelineno-2-3" href="#__codelineno-2-3"></a><span class="w"> </span><span class="n">ktorClientEngineFactory</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">OkHttp</span>
</span><span id="__span-2-4"><a id="__codelineno-2-4" name="__codelineno-2-4" href="#__codelineno-2-4"></a><span class="w"> </span><span class="n">proxy</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">ProxyBuilder</span><span class="p">.</span><span class="na">socks</span><span class="p">(</span><span class="s">&quot;127.0.0.1&quot;</span><span class="p">,</span><span class="w"> </span><span class="m">1080</span><span class="p">)</span>
</span><span id="__span-2-5"><a id="__codelineno-2-5" name="__codelineno-2-5" href="#__codelineno-2-5"></a><span class="p">}</span>
<div class="language-kotlin highlight"><pre><span></span><code><span id="__span-2-1"><a id="__codelineno-2-1" name="__codelineno-2-1" href="#__codelineno-2-1"></a><span class="kd">val</span><span class="w"> </span><span class="nv">botToken</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;HERE MUST BE YOUR TOKEN&quot;</span><span class="w"> </span><span class="c1">// (1)</span>
</span><span id="__span-2-2"><a id="__codelineno-2-2" name="__codelineno-2-2" href="#__codelineno-2-2"></a><span class="kd">val</span><span class="w"> </span><span class="nv">bot</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">telegramBot</span><span class="p">(</span><span class="n">botToken</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="c1">// (2)</span>
</span><span id="__span-2-3"><a id="__codelineno-2-3" name="__codelineno-2-3" href="#__codelineno-2-3"></a><span class="w"> </span><span class="n">client</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">HttpClient</span><span class="p">(</span><span class="n">OkHttp</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="c1">// (3)</span>
</span><span id="__span-2-4"><a id="__codelineno-2-4" name="__codelineno-2-4" href="#__codelineno-2-4"></a><span class="w"> </span><span class="n">engine</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="c1">// (4)</span>
</span><span id="__span-2-5"><a id="__codelineno-2-5" name="__codelineno-2-5" href="#__codelineno-2-5"></a><span class="w"> </span><span class="n">config</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="c1">// (5)</span>
</span><span id="__span-2-6"><a id="__codelineno-2-6" name="__codelineno-2-6" href="#__codelineno-2-6"></a><span class="w"> </span><span class="n">proxy</span><span class="p">(</span><span class="w"> </span><span class="c1">// (6)</span>
</span><span id="__span-2-7"><a id="__codelineno-2-7" name="__codelineno-2-7" href="#__codelineno-2-7"></a><span class="w"> </span><span class="n">Proxy</span><span class="p">(</span><span class="w"> </span><span class="c1">// (7)</span>
</span><span id="__span-2-8"><a id="__codelineno-2-8" name="__codelineno-2-8" href="#__codelineno-2-8"></a><span class="w"> </span><span class="n">Proxy</span><span class="p">.</span><span class="na">Type</span><span class="p">.</span><span class="na">SOCKS</span><span class="p">,</span><span class="w"> </span><span class="c1">// (8)</span>
</span><span id="__span-2-9"><a id="__codelineno-2-9" name="__codelineno-2-9" href="#__codelineno-2-9"></a><span class="w"> </span><span class="n">InetSocketAddress</span><span class="p">(</span><span class="s">&quot;127.0.0.1&quot;</span><span class="p">,</span><span class="w"> </span><span class="m">1080</span><span class="p">)</span><span class="w"> </span><span class="c1">// (9)</span>
</span><span id="__span-2-10"><a id="__codelineno-2-10" name="__codelineno-2-10" href="#__codelineno-2-10"></a><span class="w"> </span><span class="p">)</span>
</span><span id="__span-2-11"><a id="__codelineno-2-11" name="__codelineno-2-11" href="#__codelineno-2-11"></a><span class="w"> </span><span class="p">)</span>
</span><span id="__span-2-12"><a id="__codelineno-2-12" name="__codelineno-2-12" href="#__codelineno-2-12"></a><span class="w"> </span><span class="p">}</span>
</span><span id="__span-2-13"><a id="__codelineno-2-13" name="__codelineno-2-13" href="#__codelineno-2-13"></a><span class="w"> </span><span class="p">}</span>
</span><span id="__span-2-14"><a id="__codelineno-2-14" name="__codelineno-2-14" href="#__codelineno-2-14"></a><span class="w"> </span><span class="p">}</span>
</span><span id="__span-2-15"><a id="__codelineno-2-15" name="__codelineno-2-15" href="#__codelineno-2-15"></a><span class="p">}</span>
</span></code></pre></div>
<p>Explanation line by line:</p>
<ol>
<li><code>val botToken = "HERE MUST BE YOUR TOKEN"</code> - here we are just creating variable <code>botToken</code></li>
<li><code>val bot = telegramBot(botToken) {</code> - start creating bot</li>
<li><code>ktorClientEngineFactory = OkHttp</code> - setting up engine factory of our bot. On the time of documentation filling, <code>OkHttp</code> is one of the engines in <code>Ktor</code> system which supports socks proxy. More you can read on <a href="https://ktor.io">Ktor</a> site in subparts about <a href="https://ktor.io/clients/http-client/engines.html#okhttp">engines</a> and <a href="https://ktor.io/clients/http-client/features/proxy.html">proxy</a></li>
<li><code>proxy = ProxyBuilder.socks("127.0.0.1", 1080)</code> - here we are setting up our proxy. Here was used local server which (as assumed) will connect to server like <code>shadowsocks</code></li>
<li>Here we are just creating variable <code>botToken</code></li>
<li>Start creating bot</li>
<li>Setting <code>HttpClient</code> of our bot. On the time of documentation filling, <code>OkHttp</code> is one of the engines in <code>Ktor</code> system which supports socks proxy. More you can read on <a href="https://ktor.io">Ktor</a> site in subparts about <a href="https://ktor.io/docs/http-client-engines.html#okhttp">engines</a> and <a href="https://ktor.io/docs/proxy.html#socks_proxy">proxy</a></li>
<li>Start setting up of <code>HttpClient</code> engine</li>
<li>Start setting up of <code>HttpClient</code> engine configuration</li>
<li>Start setting up of proxy</li>
<li>Creating proxy info object</li>
<li>Saying that it is <code>Socks</code> proxy</li>
<li>Creating address. Note that <code>"127.0.0.1"</code> and <code>1080</code> are configurable parameters</li>
</ol>
<h2 id="more-complex-and-flexible-variant">More complex and flexible variant<a class="headerlink" href="#more-complex-and-flexible-variant" title="Permanent link">&para;</a></h2>
<p>You may try to use <a href="https://ktor.io/docs/http-client-engines.html">custom engine for ktor</a>. For example:</p>
@ -2075,34 +2089,33 @@ In the snippet above was used version <code>2.0.1</code> which is actual for <co
</span><span id="__span-3-3"><a id="__codelineno-3-3" name="__codelineno-3-3" href="#__codelineno-3-3"></a><span class="c1">// Socks5 proxy</span>
</span><span id="__span-3-4"><a id="__codelineno-3-4" name="__codelineno-3-4" href="#__codelineno-3-4"></a>
</span><span id="__span-3-5"><a id="__codelineno-3-5" name="__codelineno-3-5" href="#__codelineno-3-5"></a><span class="kd">val</span><span class="w"> </span><span class="nv">bot</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">telegramBot</span><span class="p">(</span><span class="n">botToken</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
</span><span id="__span-3-6"><a id="__codelineno-3-6" name="__codelineno-3-6" href="#__codelineno-3-6"></a><span class="w"> </span><span class="kd">val</span><span class="w"> </span><span class="nv">proxyPort</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="m">1080</span><span class="w"> </span><span class="c1">//your proxy port</span>
</span><span id="__span-3-7"><a id="__codelineno-3-7" name="__codelineno-3-7" href="#__codelineno-3-7"></a>
</span><span id="__span-3-8"><a id="__codelineno-3-8" name="__codelineno-3-8" href="#__codelineno-3-8"></a><span class="w"> </span><span class="kd">val</span><span class="w"> </span><span class="nv">proxyHost</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;your proxy host&quot;</span>
</span><span id="__span-3-9"><a id="__codelineno-3-9" name="__codelineno-3-9" href="#__codelineno-3-9"></a><span class="w"> </span><span class="kd">val</span><span class="w"> </span><span class="nv">username</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;proxy username&quot;</span>
</span><span id="__span-3-10"><a id="__codelineno-3-10" name="__codelineno-3-10" href="#__codelineno-3-10"></a><span class="w"> </span><span class="kd">val</span><span class="w"> </span><span class="nv">password</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;proxy password&quot;</span>
</span><span id="__span-3-11"><a id="__codelineno-3-11" name="__codelineno-3-11" href="#__codelineno-3-11"></a>
</span><span id="__span-3-12"><a id="__codelineno-3-12" name="__codelineno-3-12" href="#__codelineno-3-12"></a><span class="w"> </span><span class="kd">val</span><span class="w"> </span><span class="nv">proxyAddr</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">InetSocketAddress</span><span class="p">(</span><span class="n">proxyHost</span><span class="p">,</span><span class="w"> </span><span class="n">proxyPort</span><span class="p">)</span>
</span><span id="__span-3-13"><a id="__codelineno-3-13" name="__codelineno-3-13" href="#__codelineno-3-13"></a><span class="w"> </span><span class="kd">val</span><span class="w"> </span><span class="nv">proxy</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Proxy</span><span class="p">(</span><span class="n">Proxy</span><span class="p">.</span><span class="na">Type</span><span class="p">.</span><span class="na">SOCKS</span><span class="p">,</span><span class="w"> </span><span class="n">proxyAddr</span><span class="p">)</span>
</span><span id="__span-3-14"><a id="__codelineno-3-14" name="__codelineno-3-14" href="#__codelineno-3-14"></a>
</span><span id="__span-3-15"><a id="__codelineno-3-15" name="__codelineno-3-15" href="#__codelineno-3-15"></a><span class="w"> </span><span class="n">Authenticator</span><span class="p">.</span><span class="na">setDefault</span><span class="p">(</span><span class="k">object</span><span class="w"> </span><span class="p">:</span><span class="w"> </span><span class="nc">Authenticator</span><span class="p">()</span><span class="w"> </span><span class="p">{</span>
</span><span id="__span-3-16"><a id="__codelineno-3-16" name="__codelineno-3-16" href="#__codelineno-3-16"></a><span class="w"> </span><span class="kd">protected</span><span class="w"> </span><span class="kd">val</span><span class="w"> </span><span class="nv">passwordAuthentication</span><span class="p">:</span><span class="w"> </span><span class="n">PasswordAuthentication?</span>
</span><span id="__span-3-17"><a id="__codelineno-3-17" name="__codelineno-3-17" href="#__codelineno-3-17"></a><span class="w"> </span><span class="n">protected</span><span class="w"> </span><span class="k">get</span><span class="p">()</span><span class="w"> </span><span class="p">{</span>
</span><span id="__span-3-18"><a id="__codelineno-3-18" name="__codelineno-3-18" href="#__codelineno-3-18"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">requestingHost</span><span class="p">.</span><span class="na">lowercase</span><span class="p">()</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="n">proxyHost</span><span class="p">.</span><span class="na">lowercase</span><span class="p">())</span><span class="w"> </span><span class="p">{</span>
</span><span id="__span-3-19"><a id="__codelineno-3-19" name="__codelineno-3-19" href="#__codelineno-3-19"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">proxyPort</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="n">requestingPort</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
</span><span id="__span-3-20"><a id="__codelineno-3-20" name="__codelineno-3-20" href="#__codelineno-3-20"></a><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">PasswordAuthentication</span><span class="p">(</span><span class="n">username</span><span class="p">,</span><span class="w"> </span><span class="n">password</span><span class="p">.</span><span class="na">toCharArray</span><span class="p">())</span>
</span><span id="__span-3-21"><a id="__codelineno-3-21" name="__codelineno-3-21" href="#__codelineno-3-21"></a><span class="w"> </span><span class="p">}</span>
</span><span id="__span-3-22"><a id="__codelineno-3-22" name="__codelineno-3-22" href="#__codelineno-3-22"></a><span class="w"> </span><span class="p">}</span>
</span><span id="__span-3-23"><a id="__codelineno-3-23" name="__codelineno-3-23" href="#__codelineno-3-23"></a><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="kc">null</span>
</span><span id="__span-3-24"><a id="__codelineno-3-24" name="__codelineno-3-24" href="#__codelineno-3-24"></a><span class="w"> </span><span class="p">}</span>
</span><span id="__span-3-25"><a id="__codelineno-3-25" name="__codelineno-3-25" href="#__codelineno-3-25"></a><span class="w"> </span><span class="p">})</span>
</span><span id="__span-3-26"><a id="__codelineno-3-26" name="__codelineno-3-26" href="#__codelineno-3-26"></a><span class="w"> </span><span class="k">this</span><span class="p">.</span><span class="na">client</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">HttpClient</span><span class="p">(</span><span class="n">OkHttp</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
</span><span id="__span-3-27"><a id="__codelineno-3-27" name="__codelineno-3-27" href="#__codelineno-3-27"></a><span class="w"> </span><span class="n">engine</span><span class="w"> </span><span class="p">{</span>
</span><span id="__span-3-28"><a id="__codelineno-3-28" name="__codelineno-3-28" href="#__codelineno-3-28"></a><span class="w"> </span><span class="n">config</span><span class="w"> </span><span class="p">{</span>
</span><span id="__span-3-29"><a id="__codelineno-3-29" name="__codelineno-3-29" href="#__codelineno-3-29"></a><span class="w"> </span><span class="n">proxy</span><span class="p">(</span><span class="n">proxy</span><span class="p">)</span>
</span><span id="__span-3-30"><a id="__codelineno-3-30" name="__codelineno-3-30" href="#__codelineno-3-30"></a><span class="w"> </span><span class="p">}</span>
</span><span id="__span-3-31"><a id="__codelineno-3-31" name="__codelineno-3-31" href="#__codelineno-3-31"></a><span class="w"> </span><span class="p">}</span>
</span><span id="__span-3-32"><a id="__codelineno-3-32" name="__codelineno-3-32" href="#__codelineno-3-32"></a><span class="w"> </span><span class="p">}</span>
</span><span id="__span-3-33"><a id="__codelineno-3-33" name="__codelineno-3-33" href="#__codelineno-3-33"></a><span class="p">}</span>
</span><span id="__span-3-6"><a id="__codelineno-3-6" name="__codelineno-3-6" href="#__codelineno-3-6"></a><span class="w"> </span><span class="kd">val</span><span class="w"> </span><span class="nv">proxyHost</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;your proxy host&quot;</span>
</span><span id="__span-3-7"><a id="__codelineno-3-7" name="__codelineno-3-7" href="#__codelineno-3-7"></a><span class="w"> </span><span class="kd">val</span><span class="w"> </span><span class="nv">proxyPort</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="m">1080</span><span class="w"> </span><span class="c1">//your proxy port</span>
</span><span id="__span-3-8"><a id="__codelineno-3-8" name="__codelineno-3-8" href="#__codelineno-3-8"></a><span class="w"> </span><span class="kd">val</span><span class="w"> </span><span class="nv">username</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;proxy username&quot;</span>
</span><span id="__span-3-9"><a id="__codelineno-3-9" name="__codelineno-3-9" href="#__codelineno-3-9"></a><span class="w"> </span><span class="kd">val</span><span class="w"> </span><span class="nv">password</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;proxy password&quot;</span>
</span><span id="__span-3-10"><a id="__codelineno-3-10" name="__codelineno-3-10" href="#__codelineno-3-10"></a>
</span><span id="__span-3-11"><a id="__codelineno-3-11" name="__codelineno-3-11" href="#__codelineno-3-11"></a><span class="w"> </span><span class="kd">val</span><span class="w"> </span><span class="nv">proxyAddr</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">InetSocketAddress</span><span class="p">(</span><span class="n">proxyHost</span><span class="p">,</span><span class="w"> </span><span class="n">proxyPort</span><span class="p">)</span>
</span><span id="__span-3-12"><a id="__codelineno-3-12" name="__codelineno-3-12" href="#__codelineno-3-12"></a><span class="w"> </span><span class="kd">val</span><span class="w"> </span><span class="nv">proxy</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Proxy</span><span class="p">(</span><span class="n">Proxy</span><span class="p">.</span><span class="na">Type</span><span class="p">.</span><span class="na">SOCKS</span><span class="p">,</span><span class="w"> </span><span class="n">proxyAddr</span><span class="p">)</span>
</span><span id="__span-3-13"><a id="__codelineno-3-13" name="__codelineno-3-13" href="#__codelineno-3-13"></a>
</span><span id="__span-3-14"><a id="__codelineno-3-14" name="__codelineno-3-14" href="#__codelineno-3-14"></a><span class="w"> </span><span class="n">Authenticator</span><span class="p">.</span><span class="na">setDefault</span><span class="p">(</span><span class="k">object</span><span class="w"> </span><span class="p">:</span><span class="w"> </span><span class="nc">Authenticator</span><span class="p">()</span><span class="w"> </span><span class="p">{</span>
</span><span id="__span-3-15"><a id="__codelineno-3-15" name="__codelineno-3-15" href="#__codelineno-3-15"></a><span class="w"> </span><span class="kd">protected</span><span class="w"> </span><span class="kd">val</span><span class="w"> </span><span class="nv">passwordAuthentication</span><span class="p">:</span><span class="w"> </span><span class="n">PasswordAuthentication?</span>
</span><span id="__span-3-16"><a id="__codelineno-3-16" name="__codelineno-3-16" href="#__codelineno-3-16"></a><span class="w"> </span><span class="n">protected</span><span class="w"> </span><span class="k">get</span><span class="p">()</span><span class="w"> </span><span class="p">{</span>
</span><span id="__span-3-17"><a id="__codelineno-3-17" name="__codelineno-3-17" href="#__codelineno-3-17"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">requestingHost</span><span class="p">.</span><span class="na">lowercase</span><span class="p">()</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="n">proxyHost</span><span class="p">.</span><span class="na">lowercase</span><span class="p">())</span><span class="w"> </span><span class="p">{</span>
</span><span id="__span-3-18"><a id="__codelineno-3-18" name="__codelineno-3-18" href="#__codelineno-3-18"></a><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">proxyPort</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="n">requestingPort</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
</span><span id="__span-3-19"><a id="__codelineno-3-19" name="__codelineno-3-19" href="#__codelineno-3-19"></a><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">PasswordAuthentication</span><span class="p">(</span><span class="n">username</span><span class="p">,</span><span class="w"> </span><span class="n">password</span><span class="p">.</span><span class="na">toCharArray</span><span class="p">())</span>
</span><span id="__span-3-20"><a id="__codelineno-3-20" name="__codelineno-3-20" href="#__codelineno-3-20"></a><span class="w"> </span><span class="p">}</span>
</span><span id="__span-3-21"><a id="__codelineno-3-21" name="__codelineno-3-21" href="#__codelineno-3-21"></a><span class="w"> </span><span class="p">}</span>
</span><span id="__span-3-22"><a id="__codelineno-3-22" name="__codelineno-3-22" href="#__codelineno-3-22"></a><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="kc">null</span>
</span><span id="__span-3-23"><a id="__codelineno-3-23" name="__codelineno-3-23" href="#__codelineno-3-23"></a><span class="w"> </span><span class="p">}</span>
</span><span id="__span-3-24"><a id="__codelineno-3-24" name="__codelineno-3-24" href="#__codelineno-3-24"></a><span class="w"> </span><span class="p">})</span>
</span><span id="__span-3-25"><a id="__codelineno-3-25" name="__codelineno-3-25" href="#__codelineno-3-25"></a><span class="w"> </span><span class="k">this</span><span class="p">.</span><span class="na">client</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">HttpClient</span><span class="p">(</span><span class="n">OkHttp</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
</span><span id="__span-3-26"><a id="__codelineno-3-26" name="__codelineno-3-26" href="#__codelineno-3-26"></a><span class="w"> </span><span class="n">engine</span><span class="w"> </span><span class="p">{</span>
</span><span id="__span-3-27"><a id="__codelineno-3-27" name="__codelineno-3-27" href="#__codelineno-3-27"></a><span class="w"> </span><span class="n">config</span><span class="w"> </span><span class="p">{</span>
</span><span id="__span-3-28"><a id="__codelineno-3-28" name="__codelineno-3-28" href="#__codelineno-3-28"></a><span class="w"> </span><span class="n">proxy</span><span class="p">(</span><span class="n">proxy</span><span class="p">)</span>
</span><span id="__span-3-29"><a id="__codelineno-3-29" name="__codelineno-3-29" href="#__codelineno-3-29"></a><span class="w"> </span><span class="p">}</span>
</span><span id="__span-3-30"><a id="__codelineno-3-30" name="__codelineno-3-30" href="#__codelineno-3-30"></a><span class="w"> </span><span class="p">}</span>
</span><span id="__span-3-31"><a id="__codelineno-3-31" name="__codelineno-3-31" href="#__codelineno-3-31"></a><span class="w"> </span><span class="p">}</span>
</span><span id="__span-3-32"><a id="__codelineno-3-32" name="__codelineno-3-32" href="#__codelineno-3-32"></a><span class="p">}</span>
</span></code></pre></div>
<h2 id="next-steps">Next steps<a class="headerlink" href="#next-steps" title="Permanent link">&para;</a></h2>
<ul>