[yast-commit] r59672 - /branches/SuSE-Code-11-SP1-Branch/network/src/services/proxy.ycp
Author: kmachalkova Date: Fri Nov 20 15:14:41 2009 New Revision: 59672 URL: http://svn.opensuse.org/viewcvs/yast?rev=59672&view=rev Log: Validate no proxy domains (incl. subnets) Modified: branches/SuSE-Code-11-SP1-Branch/network/src/services/proxy.ycp Modified: branches/SuSE-Code-11-SP1-Branch/network/src/services/proxy.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/network/src/services/proxy.ycp?rev=59672&r1=59671&r2=59672&view=diff ============================================================================== --- branches/SuSE-Code-11-SP1-Branch/network/src/services/proxy.ycp (original) +++ branches/SuSE-Code-11-SP1-Branch/network/src/services/proxy.ycp Fri Nov 20 15:14:41 2009 @@ -11,9 +11,11 @@ textdomain "network"; +import "Address"; import "Hostname"; import "Label"; import "Mode"; +import "Netmask"; import "Popup"; import "Proxy"; import "String"; @@ -258,6 +260,39 @@ } } +boolean ValidateNoProxyDomains( string no_proxies ) { + list <string> proxy_list = splitstring( no_proxies, ","); + boolean validate = true; + string hostname = ""; + string netmask = ""; + + foreach( string one_proxy, proxy_list, { + one_proxy = String::CutBlanks( one_proxy ); + + // IP/netmask + if ( findfirstof( one_proxy, "/" ) != nil ) { + list <string> tmp = splitstring(hostname,"/"); + hostname = tmp[0]:""; + netmask = tmp[1]:""; + + if (!Netmask::Check( netmask )) + validate = false; + } + // hostname or domain name + else { + hostname = one_proxy; + // .domain.name case + if ( findfirstof( hostname, ".") == 0) + hostname = substring(hostname, 1); + } + y2milestone("hostname %1, netmask %2", hostname, netmask); + + if (!Address::Check(hostname)) + validate = false; + }); + + return validate; +} /** * Proxy dialog * @param standalone true if not run from another ycp client @@ -457,9 +492,6 @@ enabled = (boolean) UI::QueryWidget(`id(`enabled), `Value); no = (string) UI::QueryWidget(`id(`no), `Value); - list<string> no_list = splitstring (no, " ,"); - no_list = filter (string no_i, no_list, ``( no_i != "") ); - no = mergestring (no_list, ", "); if(http == prefill) http = ""; if(https == prefill) https = ""; @@ -527,6 +559,19 @@ continue; } } + if ( no != "" && no != nil) { + if (!ValidateNoProxyDomains( no )) { + //Translators: no proxy domain is a domain that can be accessed without proxy + Popup::Error(_("One or more no proxy domains are invalid. +Check if all domains match one of the following: +* IP address +* IP address/netmask +* Fully qualified hostname +* Domain name prefixed by '.'")); + UI::SetFocus(`id(`no)); + continue; + } + } if (ret == `next) { break; @@ -555,6 +600,7 @@ return ret; } + Proxy::enabled = enabled; if(enabled) { Proxy::http = http; -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
kmachalkova@svn.opensuse.org