luci: support proxy server settings.
This commit is contained in:
@@ -269,6 +269,21 @@ msgstr "未运行"
|
|||||||
msgid "No check certificate"
|
msgid "No check certificate"
|
||||||
msgstr "停用证书校验"
|
msgstr "停用证书校验"
|
||||||
|
|
||||||
|
msgid "Please set proxy server first."
|
||||||
|
msgstr "请先设置代理服务器。"
|
||||||
|
|
||||||
|
msgid "Proxy Server"
|
||||||
|
msgstr "代理服务器"
|
||||||
|
|
||||||
|
msgid "Proxy Server URL, format: [socks5|http]://user:pass@ip:port."
|
||||||
|
msgstr "代理服务器地址,格式:[socks5|http]://user:pass@ip:port。"
|
||||||
|
|
||||||
|
msgid "Proxy server URL format error, format: [socks5|http]://user:pass@ip:port."
|
||||||
|
msgstr "代理服务器地址格式错误,格式:[socks5|http]://user:pass@ip:port。"
|
||||||
|
|
||||||
|
msgid "Proxy Server Settings"
|
||||||
|
msgstr "代理服务器设置"
|
||||||
|
|
||||||
msgid "Query DNS through specific dns server group, such as office, home."
|
msgid "Query DNS through specific dns server group, such as office, home."
|
||||||
msgstr "使用指定服务器组查询,比如office, home。"
|
msgstr "使用指定服务器组查询,比如office, home。"
|
||||||
|
|
||||||
@@ -431,6 +446,12 @@ msgstr "设置所有域名的 TTL 值。"
|
|||||||
msgid "Technical Support"
|
msgid "Technical Support"
|
||||||
msgstr "技术支持"
|
msgstr "技术支持"
|
||||||
|
|
||||||
|
msgid "Use Proxy"
|
||||||
|
msgstr "使用代理"
|
||||||
|
|
||||||
|
msgid "Use proxy to connect to upstream DNS server."
|
||||||
|
msgstr "使用代理连接上游DNS服务器。"
|
||||||
|
|
||||||
msgid "URL"
|
msgid "URL"
|
||||||
msgstr "URL"
|
msgstr "URL"
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ s.anonymous = true
|
|||||||
s:tab("settings", translate("General Settings"))
|
s:tab("settings", translate("General Settings"))
|
||||||
s:tab("advanced", translate('Advanced Settings'))
|
s:tab("advanced", translate('Advanced Settings'))
|
||||||
s:tab("seconddns", translate("Second Server Settings"))
|
s:tab("seconddns", translate("Second Server Settings"))
|
||||||
|
s:tab("proxy", translate("Proxy Server Settings"))
|
||||||
s:tab("custom", translate("Custom Settings"))
|
s:tab("custom", translate("Custom Settings"))
|
||||||
|
|
||||||
---- Eanble
|
---- Eanble
|
||||||
@@ -312,6 +313,21 @@ o.cfgvalue = function(...)
|
|||||||
return Flag.cfgvalue(...) or "0"
|
return Flag.cfgvalue(...) or "0"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
----- Proxy server settings
|
||||||
|
o = s:taboption("proxy", Value, "proxy_server", translate("Proxy Server"), translate("Proxy Server URL, format: [socks5|http]://user:pass@ip:port."));
|
||||||
|
o.datatype = 'string';
|
||||||
|
function o.validate(self, value)
|
||||||
|
if (value == "") then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
if (not value:match("^http://") and not value:match("^socks5://")) then
|
||||||
|
return nil, translate("Proxy server URL format error, format: [socks5|http]://user:pass@ip:port.")
|
||||||
|
end
|
||||||
|
|
||||||
|
return value
|
||||||
|
end
|
||||||
|
|
||||||
----- custom settings
|
----- custom settings
|
||||||
custom = s:taboption("custom", Value, "Custom Settings",
|
custom = s:taboption("custom", Value, "Custom Settings",
|
||||||
translate(""),
|
translate(""),
|
||||||
|
|||||||
@@ -133,6 +133,23 @@ o.default = ""
|
|||||||
o.rempty = true
|
o.rempty = true
|
||||||
o.datatype = "uinteger"
|
o.datatype = "uinteger"
|
||||||
|
|
||||||
|
---- use proxy
|
||||||
|
o = s:option(Flag, "use_proxy", translate("Use Proxy"), translate("Use proxy to connect to upstream DNS server."))
|
||||||
|
o.rmempty = true
|
||||||
|
o.default = o.disabled
|
||||||
|
o.cfgvalue = function(...)
|
||||||
|
return Flag.cfgvalue(...) or "0"
|
||||||
|
end
|
||||||
|
function o.validate(self, value, section)
|
||||||
|
if value == "1" then
|
||||||
|
local proxy = m.uci:get_first("smartdns", "smartdns", "proxy_server")
|
||||||
|
if proxy == nil or proxy == "" then
|
||||||
|
return nil, translate("Please set proxy server first.")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return value
|
||||||
|
end
|
||||||
|
|
||||||
---- other args
|
---- other args
|
||||||
o = s:option(Value, "addition_arg", translate("Additional Server Args"), translate("Additional Args for upstream dns servers"))
|
o = s:option(Value, "addition_arg", translate("Additional Server Args"), translate("Additional Args for upstream dns servers"))
|
||||||
o.default = ""
|
o.default = ""
|
||||||
|
|||||||
@@ -301,6 +301,24 @@ msgstr "停用证书校验"
|
|||||||
msgid "None"
|
msgid "None"
|
||||||
msgstr "无"
|
msgstr "无"
|
||||||
|
|
||||||
|
msgid "Only socks5 proxy support udp server."
|
||||||
|
msgstr "仅SOCKS5代理支持UDP服务器。"
|
||||||
|
|
||||||
|
msgid "Please set proxy server first."
|
||||||
|
msgstr "请先设置代理服务器。"
|
||||||
|
|
||||||
|
msgid "Proxy Server"
|
||||||
|
msgstr "代理服务器"
|
||||||
|
|
||||||
|
msgid "Proxy Server URL, format: [socks5|http]://user:pass@ip:port."
|
||||||
|
msgstr "代理服务器地址,格式:[socks5|http]://user:pass@ip:port。"
|
||||||
|
|
||||||
|
msgid "Proxy server URL format error, format: [socks5|http]://user:pass@ip:port."
|
||||||
|
msgstr "代理服务器地址格式错误,格式:[socks5|http]://user:pass@ip:port。"
|
||||||
|
|
||||||
|
msgid "Proxy Server Settings"
|
||||||
|
msgstr "代理服务器设置"
|
||||||
|
|
||||||
msgid "Query DNS through specific dns server group, such as office, home."
|
msgid "Query DNS through specific dns server group, such as office, home."
|
||||||
msgstr "使用指定服务器组查询,比如office, home。"
|
msgstr "使用指定服务器组查询,比如office, home。"
|
||||||
|
|
||||||
@@ -463,6 +481,12 @@ msgstr "设置所有域名的 TTL 值。"
|
|||||||
msgid "Technical Support"
|
msgid "Technical Support"
|
||||||
msgstr "技术支持"
|
msgstr "技术支持"
|
||||||
|
|
||||||
|
msgid "Use Proxy"
|
||||||
|
msgstr "使用代理"
|
||||||
|
|
||||||
|
msgid "Use proxy to connect to upstream DNS server."
|
||||||
|
msgstr "使用代理连接上游DNS服务器。"
|
||||||
|
|
||||||
msgid "URL"
|
msgid "URL"
|
||||||
msgstr "URL"
|
msgstr "URL"
|
||||||
|
|
||||||
|
|||||||
@@ -132,6 +132,7 @@ return view.extend({
|
|||||||
s.tab("advanced", _('Advanced Settings'));
|
s.tab("advanced", _('Advanced Settings'));
|
||||||
s.tab("seconddns", _("Second Server Settings"));
|
s.tab("seconddns", _("Second Server Settings"));
|
||||||
s.tab("files", _("Download Files Setting"), _("Download domain list files for domain-rule and include config files, please refresh the page after download to take effect."));
|
s.tab("files", _("Download Files Setting"), _("Download domain list files for domain-rule and include config files, please refresh the page after download to take effect."));
|
||||||
|
s.tab("proxy", _("Proxy Server Settings"));
|
||||||
s.tab("custom", _("Custom Settings"));
|
s.tab("custom", _("Custom Settings"));
|
||||||
|
|
||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
@@ -444,6 +445,23 @@ return view.extend({
|
|||||||
so.rmempty = true;
|
so.rmempty = true;
|
||||||
so.datatype = 'string';
|
so.datatype = 'string';
|
||||||
|
|
||||||
|
///////////////////////////////////////
|
||||||
|
// Proxy server settings;
|
||||||
|
///////////////////////////////////////
|
||||||
|
o = s.taboption("proxy", form.Value, "proxy_server", _("Proxy Server"), _("Proxy Server URL, format: [socks5|http]://user:pass@ip:port."));
|
||||||
|
o.datatype = 'string';
|
||||||
|
o.validate = function (section_id, value) {
|
||||||
|
if (value == "") {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!value.match(/^(socks5|http):\/\//)) {
|
||||||
|
return _("Proxy server URL format error, format: [socks5|http]://user:pass@ip:port.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
// custom settings;
|
// custom settings;
|
||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
@@ -602,6 +620,32 @@ return view.extend({
|
|||||||
o.rempty = true
|
o.rempty = true
|
||||||
o.datatype = "uinteger"
|
o.datatype = "uinteger"
|
||||||
o.modalonly = true;
|
o.modalonly = true;
|
||||||
|
|
||||||
|
// use proxy
|
||||||
|
o = s.taboption("advanced", form.Flag, "use_proxy", _("Use Proxy"),
|
||||||
|
_("Use proxy to connect to upstream DNS server."))
|
||||||
|
o.default = o.disabled
|
||||||
|
o.modalonly = true;
|
||||||
|
o.optional = true;
|
||||||
|
o.rempty = true;
|
||||||
|
o.validate = function(section_id, value) {
|
||||||
|
var flag = this.formvalue(section_id);
|
||||||
|
if (flag == "0") {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
var proxy_server = uci.sections("smartdns", "smartdns")[0].proxy_server;
|
||||||
|
var server_type = this.section.formvalue(section_id, "type");
|
||||||
|
if (proxy_server == "" || proxy_server == undefined) {
|
||||||
|
return _("Please set proxy server first.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (server_type == "udp" && !proxy_server.match(/^(socks5):\/\//)) {
|
||||||
|
return _("Only socks5 proxy support udp server.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// other args
|
// other args
|
||||||
o = s.taboption("advanced", form.Value, "addition_arg", _("Additional Server Args"),
|
o = s.taboption("advanced", form.Value, "addition_arg", _("Additional Server Args"),
|
||||||
|
|||||||
@@ -184,6 +184,7 @@ load_server()
|
|||||||
config_get spki_pin "$section" "spki_pin" ""
|
config_get spki_pin "$section" "spki_pin" ""
|
||||||
config_get addition_arg "$section" "addition_arg" ""
|
config_get addition_arg "$section" "addition_arg" ""
|
||||||
config_get set_mark "$section" "set_mark" ""
|
config_get set_mark "$section" "set_mark" ""
|
||||||
|
config_get_bool use_proxy "$section" "use_proxy" "0"
|
||||||
|
|
||||||
[ "$enabled" = "0" ] && return
|
[ "$enabled" = "0" ] && return
|
||||||
|
|
||||||
@@ -216,6 +217,7 @@ load_server()
|
|||||||
[ "$check_edns" = "0" ] || ADDITIONAL_ARGS="$ADDITIONAL_ARGS -check-edns"
|
[ "$check_edns" = "0" ] || ADDITIONAL_ARGS="$ADDITIONAL_ARGS -check-edns"
|
||||||
[ -z "$spki_pin" ] || ADDITIONAL_ARGS="$ADDITIONAL_ARGS -spki-pin $spki_pin"
|
[ -z "$spki_pin" ] || ADDITIONAL_ARGS="$ADDITIONAL_ARGS -spki-pin $spki_pin"
|
||||||
[ -z "$set_mark" ] || ADDITIONAL_ARGS="$ADDITIONAL_ARGS -set-mark $set_mark"
|
[ -z "$set_mark" ] || ADDITIONAL_ARGS="$ADDITIONAL_ARGS -set-mark $set_mark"
|
||||||
|
[ "$use_proxy" = "0" ] || ADDITIONAL_ARGS="$ADDITIONAL_ARGS -proxy default-proxy"
|
||||||
|
|
||||||
if [ -z "$port" ]; then
|
if [ -z "$port" ]; then
|
||||||
DNS_ADDRESS="$ip"
|
DNS_ADDRESS="$ip"
|
||||||
@@ -533,6 +535,9 @@ load_service()
|
|||||||
config_get_bool bind_device "$section" "bind_device" "0"
|
config_get_bool bind_device "$section" "bind_device" "0"
|
||||||
config_get bind_device_name "$section" "bind_device_name" "${lan_device}"
|
config_get bind_device_name "$section" "bind_device_name" "${lan_device}"
|
||||||
[ ! -z "$bind_device_name" ] && [ "$bind_device" = "1" ] && device="${bind_device_name}"
|
[ ! -z "$bind_device_name" ] && [ "$bind_device" = "1" ] && device="${bind_device_name}"
|
||||||
|
|
||||||
|
config_get proxy_server "$section" "proxy_server" ""
|
||||||
|
[ -z "$proxy_server" ] || conf_append "proxy-server" "$proxy_server -name default-proxy"
|
||||||
|
|
||||||
config_get redirect "$section" "redirect" ""
|
config_get redirect "$section" "redirect" ""
|
||||||
config_get old_port "$section" "old_port" "0"
|
config_get old_port "$section" "old_port" "0"
|
||||||
|
|||||||
@@ -1693,7 +1693,7 @@ static int _dns_client_create_socket_udp_proxy(struct dns_server_info *server_in
|
|||||||
|
|
||||||
proxy = proxy_conn_new(server_info->proxy_name, server_info->ip, server_info->port, 1);
|
proxy = proxy_conn_new(server_info->proxy_name, server_info->ip, server_info->port, 1);
|
||||||
if (proxy == NULL) {
|
if (proxy == NULL) {
|
||||||
tlog(TLOG_ERROR, "create proxy failed, %s", server_info->ip);
|
tlog(TLOG_ERROR, "create proxy failed, %s, proxy: %s", server_info->ip, server_info->proxy_name);
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1837,7 +1837,7 @@ static int _DNS_client_create_socket_tcp(struct dns_server_info *server_info)
|
|||||||
if (server_info->proxy_name[0] != '\0') {
|
if (server_info->proxy_name[0] != '\0') {
|
||||||
proxy = proxy_conn_new(server_info->proxy_name, server_info->ip, server_info->port, 0);
|
proxy = proxy_conn_new(server_info->proxy_name, server_info->ip, server_info->port, 0);
|
||||||
if (proxy == NULL) {
|
if (proxy == NULL) {
|
||||||
tlog(TLOG_ERROR, "create proxy failed, %s", server_info->ip);
|
tlog(TLOG_ERROR, "create proxy failed, %s, proxy: %s", server_info->ip, server_info->proxy_name);
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
fd = proxy_conn_get_fd(proxy);
|
fd = proxy_conn_get_fd(proxy);
|
||||||
@@ -1945,7 +1945,7 @@ static int _DNS_client_create_socket_tls(struct dns_server_info *server_info, ch
|
|||||||
if (server_info->proxy_name[0] != '\0') {
|
if (server_info->proxy_name[0] != '\0') {
|
||||||
proxy = proxy_conn_new(server_info->proxy_name, server_info->ip, server_info->port, 0);
|
proxy = proxy_conn_new(server_info->proxy_name, server_info->ip, server_info->port, 0);
|
||||||
if (proxy == NULL) {
|
if (proxy == NULL) {
|
||||||
tlog(TLOG_ERROR, "create proxy failed, %s", server_info->ip);
|
tlog(TLOG_ERROR, "create proxy failed, %s, proxy: %s", server_info->ip, server_info->proxy_name);
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
fd = proxy_conn_get_fd(proxy);
|
fd = proxy_conn_get_fd(proxy);
|
||||||
|
|||||||
@@ -1638,13 +1638,13 @@ static int _config_proxy_server(void *data, int argc, char *argv[])
|
|||||||
server = malloc(sizeof(*server));
|
server = malloc(sizeof(*server));
|
||||||
if (server == NULL) {
|
if (server == NULL) {
|
||||||
tlog(TLOG_WARN, "malloc memory failed.");
|
tlog(TLOG_WARN, "malloc memory failed.");
|
||||||
return -1;
|
goto errout;
|
||||||
}
|
}
|
||||||
memset(server, 0, sizeof(*server));
|
memset(server, 0, sizeof(*server));
|
||||||
|
|
||||||
ip = argv[1];
|
ip = argv[1];
|
||||||
if (parse_uri_ext(ip, scheme, server->username, server->password, server->server, &port, NULL) != 0) {
|
if (parse_uri_ext(ip, scheme, server->username, server->password, server->server, &port, NULL) != 0) {
|
||||||
return -1;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* process extra options */
|
/* process extra options */
|
||||||
|
|||||||
Reference in New Issue
Block a user