Я пишу расширение для VPN, в нём необходимо передать код страны через SOCKS4 на локальный прокси. Как можно это грамотно сделать ? Вот основной файл, если что, чтобы было понятнее: // prettier-ignore $(document).ready(function() { loadData(); $("#search").click(search); $("#clear").click(clear); function loadData() { chrome.storage.sync.get(["ip", "port", "countryId", "proxies"], function(result) { if (result.ip && result.port) { $("#cur_proxy").empty().append("Proxy set - " + result.ip + ":" + result.port + ""); } else { $("#cur_proxy").empty().append("Proxy not used"); } $("#country_id").val(result.countryId || null); showProxies(result.proxies || null); }); } function search() { const countryId = $("#country_id").val(); if (countryId === "select") { alert("Select a country"); return; } const proxies = []; let ip = "127.0.0.1"; let port = "1080"; proxies.push(ip + ":" + port); showProxies(proxies); chrome.storage.sync.set({countryId: countryId, proxies: proxies}, null); } function showProxies(proxies) { $(proxies).each(function(i, proxy) { $("#new_proxy").append('' + proxy + ""); }); $(".proxylist").on("click", function() { const ip = "127.0.0.1"; const port = "1080"; setProxy(ip, port); }); } function setProxy(ip, port) { const config = { mode: "fixed_servers", rules: { singleProxy: { host: ip`введите сюда код`, port: port } } }; chrome.proxy.settings.set({ value: config, scope: "regular" }, null); chrome.storage.sync.set({ip: ip, port: port}, loadData); } function clear() { const config = { mode: "direct" }; chrome.proxy.settings.set({ value: config, scope: "regular" }, null); chrome.storage.sync.clear(loadData); } }); 
  • The socks protocol does not support the transmission of any data other than addresses to connect to. so just make your own extension, which both your server and your client will need to understand. while third-party clients / servers will not be able to work with it - Mike
  • And then you couldn’t show at least an approximate version of the implementation of such an extension? ... I just can’t understand how to make everything there ((( - Dmitry Butov
  • But I see you in this code just doing something with the socks settings in chrome. Chrome will not support your extensions. I meant that if you made your own server and your own socks client (instead of chrome, and not complementing it), you could provide for transmission when connecting, for example, a couple more bytes to the country - Mike
  • As an option, you can place your socks server on a set of ports and the actual port number on which the connection is going will encode the country - Mike
  • The fact is that we develop a separate server and proxy server (client application). So I need to transfer the country to the last thing. I just don’t know how to do it right, I wanted to transfer, in principle, the country in the "password" field and a separate user or simply as part of the header ... Could you not demonstrate a concrete implementation if it is not difficult? - Dmitry Butov

0