├── root ├── etc │ ├── squid │ │ └── acls │ │ │ └── .gitignore │ ├── e-smith │ │ ├── db │ │ │ ├── squid │ │ │ │ └── .gitignore │ │ │ └── configuration │ │ │ │ └── defaults │ │ │ │ └── squid │ │ │ │ ├── NoCache │ │ │ │ ├── SafePorts │ │ │ │ ├── BypassDomains │ │ │ │ ├── ParentProxy │ │ │ │ ├── BlueMode │ │ │ │ ├── MaxObjSize │ │ │ │ ├── MinObjSize │ │ │ │ ├── access │ │ │ │ ├── status │ │ │ │ ├── type │ │ │ │ ├── DiskCache │ │ │ │ ├── DiskCacheSize │ │ │ │ ├── GreenMode │ │ │ │ ├── KrbPrimaryList │ │ │ │ ├── KrbStatus │ │ │ │ ├── MemCacheSize │ │ │ │ ├── PortBlock │ │ │ │ └── TCPPorts │ │ ├── templates │ │ │ ├── var │ │ │ │ └── www │ │ │ │ │ └── html │ │ │ │ │ └── wpad.dat │ │ │ │ │ ├── 99endFunction │ │ │ │ │ ├── template-begin │ │ │ │ │ ├── 10direct │ │ │ │ │ ├── 90proxyDefault │ │ │ │ │ ├── 70proxyMode │ │ │ │ │ └── 60proxyBypass │ │ │ └── etc │ │ │ │ ├── sysconfig │ │ │ │ └── squid │ │ │ │ │ ├── 20ads │ │ │ │ │ └── 10base │ │ │ │ ├── squid │ │ │ │ ├── squid.conf │ │ │ │ │ ├── 00debug │ │ │ │ │ ├── 30http_access_99_deny_all │ │ │ │ │ ├── 10nocache │ │ │ │ │ ├── 90options │ │ │ │ │ ├── 20acl_00_portscustom │ │ │ │ │ ├── 30http_access_41_bluegreen │ │ │ │ │ ├── 30http_access_00_defaults │ │ │ │ │ ├── 20acl_00_ports │ │ │ │ │ ├── 30http_access_40_self │ │ │ │ │ ├── 20acl_00_localnet │ │ │ │ │ ├── 30http_access_50_auth │ │ │ │ │ ├── 50proxy │ │ │ │ │ ├── 40cache │ │ │ │ │ ├── 20acl_10_auth │ │ │ │ │ ├── 40ports │ │ │ │ │ └── 45marks │ │ │ │ └── acls │ │ │ │ │ └── no_cache.acl │ │ │ │ │ └── 10base │ │ │ │ ├── dnsmasq.conf │ │ │ │ ├── 25wpad │ │ │ │ └── 25squid_ipset │ │ │ │ ├── hosts │ │ │ │ └── 02wpad │ │ │ │ ├── httpd │ │ │ │ └── conf.d │ │ │ │ │ └── wpad.conf │ │ │ │ │ └── 10base │ │ │ │ └── shorewall │ │ │ │ └── rules │ │ │ │ └── 90squid │ │ ├── templates.metadata │ │ │ └── etc │ │ │ │ └── squid │ │ │ │ └── squid.conf │ │ └── events │ │ │ └── actions │ │ │ ├── nethserver-squid-httpd-reload │ │ │ ├── nethserver-squid-check-cache │ │ │ ├── nethserver-squid-ipset │ │ │ └── nethserver-squid-clear-cache │ └── systemd │ │ └── system │ │ └── dnsmasq.service.d │ │ └── ipset.conf └── usr │ └── share │ └── nethesis │ └── NethServer │ ├── Language │ └── en │ │ ├── NethServer_Module_Proxy_BypassDomains.php │ │ ├── NethServer_Module_Proxy.php │ │ ├── NethServer_Module_Proxy_Config.php │ │ ├── NethServer_Module_Proxy_BypassSrc.php │ │ ├── NethServer_Module_Proxy_BypassDst.php │ │ ├── NethServer_Module_Proxy_Rules.php │ │ └── NethServer_Module_Proxy_Squid.php │ ├── Template │ └── Proxy │ │ ├── BypassDomains.php │ │ ├── BypassModify.php │ │ ├── RulesModify.php │ │ ├── Config.php │ │ └── Squid.php │ ├── Module │ ├── Proxy.php │ └── Proxy │ │ ├── Config.php │ │ ├── BypassDomains.php │ │ ├── BypassDst.php │ │ ├── BypassSrc.php │ │ ├── Rules.php │ │ ├── Squid.php │ │ ├── BypassDst │ │ └── Modify.php │ │ ├── BypassSrc │ │ └── Modify.php │ │ └── Rules │ │ └── Modify.php │ └── Help │ └── en │ └── NethServer_Module_Proxy.rst ├── .travis.yml ├── .tx └── config ├── createlinks ├── nethserver-squid.spec ├── README.rst └── COPYING /root/etc/squid/acls/.gitignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /root/etc/e-smith/db/squid/.gitignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /root/etc/e-smith/db/configuration/defaults/squid/NoCache: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /root/etc/e-smith/db/configuration/defaults/squid/SafePorts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /root/etc/e-smith/db/configuration/defaults/squid/BypassDomains: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /root/etc/e-smith/db/configuration/defaults/squid/ParentProxy: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /root/etc/e-smith/db/configuration/defaults/squid/BlueMode: -------------------------------------------------------------------------------- 1 | manual 2 | -------------------------------------------------------------------------------- /root/etc/e-smith/db/configuration/defaults/squid/MaxObjSize: -------------------------------------------------------------------------------- 1 | 4096 2 | -------------------------------------------------------------------------------- /root/etc/e-smith/db/configuration/defaults/squid/MinObjSize: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /root/etc/e-smith/db/configuration/defaults/squid/access: -------------------------------------------------------------------------------- 1 | green 2 | -------------------------------------------------------------------------------- /root/etc/e-smith/db/configuration/defaults/squid/status: -------------------------------------------------------------------------------- 1 | disabled 2 | -------------------------------------------------------------------------------- /root/etc/e-smith/db/configuration/defaults/squid/type: -------------------------------------------------------------------------------- 1 | service 2 | -------------------------------------------------------------------------------- /root/etc/e-smith/db/configuration/defaults/squid/DiskCache: -------------------------------------------------------------------------------- 1 | disabled 2 | -------------------------------------------------------------------------------- /root/etc/e-smith/db/configuration/defaults/squid/DiskCacheSize: -------------------------------------------------------------------------------- 1 | 100 2 | -------------------------------------------------------------------------------- /root/etc/e-smith/db/configuration/defaults/squid/GreenMode: -------------------------------------------------------------------------------- 1 | manual 2 | -------------------------------------------------------------------------------- /root/etc/e-smith/db/configuration/defaults/squid/KrbPrimaryList: -------------------------------------------------------------------------------- 1 | HTTP 2 | -------------------------------------------------------------------------------- /root/etc/e-smith/db/configuration/defaults/squid/KrbStatus: -------------------------------------------------------------------------------- 1 | enabled 2 | -------------------------------------------------------------------------------- /root/etc/e-smith/db/configuration/defaults/squid/MemCacheSize: -------------------------------------------------------------------------------- 1 | 256 2 | -------------------------------------------------------------------------------- /root/etc/e-smith/db/configuration/defaults/squid/PortBlock: -------------------------------------------------------------------------------- 1 | disabled 2 | -------------------------------------------------------------------------------- /root/etc/e-smith/templates/var/www/html/wpad.dat/99endFunction: -------------------------------------------------------------------------------- 1 | \} 2 | -------------------------------------------------------------------------------- /root/etc/e-smith/db/configuration/defaults/squid/TCPPorts: -------------------------------------------------------------------------------- 1 | 3128,3129,3130 2 | -------------------------------------------------------------------------------- /root/etc/e-smith/templates.metadata/etc/squid/squid.conf: -------------------------------------------------------------------------------- 1 | PERMS=0640 2 | UID="root" 3 | GID="squid" 4 | -------------------------------------------------------------------------------- /root/etc/e-smith/events/actions/nethserver-squid-httpd-reload: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | /sbin/service httpd reload 4 | -------------------------------------------------------------------------------- /root/etc/e-smith/templates/var/www/html/wpad.dat/template-begin: -------------------------------------------------------------------------------- 1 | function FindProxyForURL(url, host) 2 | \{ 3 | -------------------------------------------------------------------------------- /root/etc/e-smith/templates/etc/sysconfig/squid/20ads: -------------------------------------------------------------------------------- 1 | # 2 | # 20ads 3 | # 4 | KRB5_KTNAME=/var/lib/misc/nsrv-squid.keytab 5 | 6 | -------------------------------------------------------------------------------- /root/etc/e-smith/templates/etc/squid/squid.conf/00debug: -------------------------------------------------------------------------------- 1 | 2 | # Uncomment this to enable debug 3 | #debug_options ALL,1 33,2 28,9 4 | 5 | -------------------------------------------------------------------------------- /root/etc/systemd/system/dnsmasq.service.d/ipset.conf: -------------------------------------------------------------------------------- 1 | [Service] 2 | ExecStartPre=/etc/e-smith/events/actions/nethserver-squid-ipset 3 | -------------------------------------------------------------------------------- /root/etc/e-smith/templates/etc/squid/squid.conf/30http_access_99_deny_all: -------------------------------------------------------------------------------- 1 | # And finally deny all other access to this proxy 2 | http_access deny all 3 | 4 | -------------------------------------------------------------------------------- /root/etc/e-smith/templates/etc/squid/squid.conf/10nocache: -------------------------------------------------------------------------------- 1 | # Sites not cached 2 | acl no_cache dstdomain "/etc/squid/acls/no_cache.acl" 3 | no_cache deny no_cache 4 | 5 | -------------------------------------------------------------------------------- /root/etc/e-smith/templates/etc/squid/squid.conf/90options: -------------------------------------------------------------------------------- 1 | # 2 | # 90options 3 | # 4 | forward_max_tries 25 5 | shutdown_lifetime 1 seconds 6 | buffered_logs on 7 | max_filedesc 16384 8 | logfile_rotate 0 9 | -------------------------------------------------------------------------------- /root/usr/share/nethesis/NethServer/Language/en/NethServer_Module_Proxy_BypassDomains.php: -------------------------------------------------------------------------------- 1 | panel() 4 | ->insert($view->textArea('BypassDomains', $view::LABEL_ABOVE)->setAttribute('dimensions', '10x50')) 5 | ; 6 | 7 | echo $view->buttonList($view::BUTTON_SUBMIT | $view::BUTTON_CANCEL | $view::BUTTON_HELP); 8 | -------------------------------------------------------------------------------- /root/etc/e-smith/templates/etc/sysconfig/squid/10base: -------------------------------------------------------------------------------- 1 | # default squid options 2 | SQUID_OPTS="" 3 | 4 | # Time to wait for Squid to shut down when asked. Should not be necessary 5 | # most of the time. 6 | SQUID_SHUTDOWN_TIMEOUT=100 7 | 8 | # default squid conf file 9 | SQUID_CONF="/etc/squid/squid.conf" 10 | 11 | -------------------------------------------------------------------------------- /root/etc/e-smith/templates/etc/dnsmasq.conf/25wpad: -------------------------------------------------------------------------------- 1 | { 2 | my $status = $squid{'status'} || 'disabled'; 3 | return "" unless ($status eq 'enabled'); 4 | $OUT.="#\n"; 5 | $OUT.="# 25wpad - Web Proxy Automatic Discovery (WPAD)\n"; 6 | $OUT.="#\n"; 7 | $OUT.="dhcp-option=252,http://$SystemName.$DomainName/wpad.dat\n\n\n"; 8 | } -------------------------------------------------------------------------------- /root/etc/e-smith/templates/etc/squid/squid.conf/30http_access_41_bluegreen: -------------------------------------------------------------------------------- 1 | { 2 | use esmith::NetworksDB; 3 | my $ndb = esmith::NetworksDB->open_ro(); 4 | if (defined($ndb->blue())) { 5 | $OUT .= "# Block access to green from other networks\n"; 6 | $OUT .= "http_access deny self blue localnet_dst\n"; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /root/usr/share/nethesis/NethServer/Language/en/NethServer_Module_Proxy.php: -------------------------------------------------------------------------------- 1 | is_owned() && $s->is_enabled() ) { 10 | push @hostnames, map { join('.', $_, $DomainName) } qw(wpad proxy) ; 11 | } 12 | ''; 13 | } 14 | -------------------------------------------------------------------------------- /root/etc/e-smith/templates/etc/dnsmasq.conf/25squid_ipset: -------------------------------------------------------------------------------- 1 | { 2 | my $status = $squid{'status'} || 'disabled'; 3 | my $list = $squid{'BypassDomains'} || ''; 4 | if ($status eq 'enabled' && $list ne '') { 5 | $list =~ s/,/\//g; 6 | $OUT.="#\n"; 7 | $OUT.="# 25squid_ipset - Squid domain bypass using ipset\n"; 8 | $OUT.="#\n"; 9 | $OUT.="ipset=/$list/squid-bypass\n\n\n"; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /root/etc/e-smith/templates/etc/squid/squid.conf/30http_access_00_defaults: -------------------------------------------------------------------------------- 1 | # Allow access from localhost 2 | http_access allow localhost 3 | 4 | # Deny requests to certain unsafe ports 5 | http_access deny !Safe_ports 6 | 7 | # Deny CONNECT to other than secure SSL ports 8 | http_access deny CONNECT !SSL_ports 9 | 10 | # Only allow cachemgr access from localhost 11 | http_access allow localhost manager 12 | http_access deny manager 13 | 14 | -------------------------------------------------------------------------------- /root/etc/e-smith/templates/var/www/html/wpad.dat/10direct: -------------------------------------------------------------------------------- 1 | { 2 | my $status = $squid{'status'} || 'disabled'; 3 | if ($status eq 'disabled') { 4 | return ''; 5 | } 6 | 7 | $OUT .=<textInput('name', ($view->getModule()->getIdentifier() == 'update' ? $view::STATE_READONLY : 0)); 4 | echo $view->checkbox('status', 'enabled') 5 | ->setAttribute('template', $T('status')) 6 | ->setAttribute('uncheckedValue', 'disabled'); 7 | echo $view->textInput('Description'); 8 | echo $view->selector('Host', $view::SELECTOR_DROPDOWN); 9 | 10 | echo $view->buttonList($view::BUTTON_SUBMIT | $view::BUTTON_CANCEL | $view::BUTTON_HELP); 11 | -------------------------------------------------------------------------------- /root/etc/e-smith/templates/etc/squid/squid.conf/20acl_00_ports: -------------------------------------------------------------------------------- 1 | # Safe ports 2 | acl SSL_ports port 443 3 | acl SSL_ports port 980 # httpd-admin (server-manager) 4 | acl Safe_ports port 80 # http 5 | acl Safe_ports port 21 # ftp 6 | acl Safe_ports port 443 # https 7 | acl Safe_ports port 70 # gopher 8 | acl Safe_ports port 210 # wais 9 | acl Safe_ports port 1025-65535 # unregistered ports 10 | acl Safe_ports port 280 # http-mgmt 11 | acl Safe_ports port 488 # gss-http 12 | acl Safe_ports port 591 # filemaker 13 | acl Safe_ports port 777 # multiling http 14 | acl Safe_ports port 980 # httpd-admin (server-manager) 15 | acl CONNECT method CONNECT 16 | 17 | -------------------------------------------------------------------------------- /root/etc/e-smith/templates/etc/squid/squid.conf/30http_access_40_self: -------------------------------------------------------------------------------- 1 | # 2 | # Skip URL rewriter for local addresses 3 | # 4 | { 5 | use esmith::NetworksDB; 6 | my $ndb = esmith::NetworksDB->open_ro(); 7 | my $blue = ''; 8 | foreach ($ndb->green()) { 9 | my $ip = $_->prop('ipaddr') || next; 10 | $OUT .= "acl self dst $ip\n"; 11 | } 12 | foreach ($ndb->blue()) { 13 | my $ip = $_->prop('ipaddr') || next; 14 | $OUT .= "acl self dst $ip\n"; 15 | $blue = ' blue '; 16 | } 17 | 18 | $OUT .= "acl self_port port 80\n"; 19 | $OUT .= "acl self_port port 443\n"; 20 | $OUT .= "url_rewrite_access deny self localnet $blue self_port\n"; 21 | } 22 | -------------------------------------------------------------------------------- /root/usr/share/nethesis/NethServer/Language/en/NethServer_Module_Proxy_BypassSrc.php: -------------------------------------------------------------------------------- 1 | textInput('id', $view::STATE_READONLY); 4 | echo $view->fieldsetSwitch('status', 'enabled', $view::FIELDSETSWITCH_CHECKBOX) 5 | ->setAttribute('template', $T('status')) 6 | ->setAttribute('uncheckedValue', 'disabled') 7 | ->insert($view->selector('Src', $view::SELECTOR_DROPDOWN)) 8 | ->insert($view->selector('Action', $view::SELECTOR_DROPDOWN)) 9 | ->insert($view->textArea('Dst', $view::LABEL_ABOVE)->setAttribute('dimensions', '10x50')) 10 | ->insert($view->textInput('Description')); 11 | 12 | echo $view->buttonList($view::BUTTON_SUBMIT | $view::BUTTON_CANCEL | $view::BUTTON_HELP); 13 | -------------------------------------------------------------------------------- /root/usr/share/nethesis/NethServer/Language/en/NethServer_Module_Proxy_BypassDst.php: -------------------------------------------------------------------------------- 1 | 9 | 10 | Order deny,allow 11 | Deny from all 12 | { 13 | use esmith::NetworksDB; 14 | use esmith::util; 15 | my $ndb = esmith::NetworksDB->open_ro() || return ''; 16 | my $localaccess = $ndb->local_access_spec(); 17 | foreach ($ndb->blue) { 18 | $localaccess .= ' '.esmith::util::computeLocalNetworkShortSpec($_->prop('ipaddr'), $_->prop('netmask')); 19 | } 20 | $OUT .= " Allow from $localaccess"; 21 | } 22 | 23 | 24 | -------------------------------------------------------------------------------- /root/usr/share/nethesis/NethServer/Language/en/NethServer_Module_Proxy_Rules.php: -------------------------------------------------------------------------------- 1 | open_ro or warn("Could not open NetworksDB"); 7 | my $LocalIP = $ndb->green()->prop('ipaddr') || return ''; 8 | my $phost = "PROXY proxy.$DomainName:3128"; 9 | my $adJoin = 0; 10 | if ( ($smb{'status'} || 'disabled') eq 'enabled' and ($smb{'ServerRole'} || '') eq 'ADS' ) { 11 | $adJoin = 1; 12 | } 13 | 14 | if ($status eq 'enabled') { 15 | my $target = "PROXY $LocalIP:3128"; 16 | if ($adJoin) { 17 | $target = $phost; 18 | } 19 | $OUT.= "\n // DEFAULT\n"; 20 | $OUT.= ' return "' . $target . '";'; 21 | } else { 22 | 23 | $OUT.= " return \"DIRECT\";\n"; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /root/usr/share/nethesis/NethServer/Template/Proxy/Config.php: -------------------------------------------------------------------------------- 1 | panel() 4 | ->insert($view->radioButton('DiskCache', 'disabled')->setAttribute('label', $T('DiskCache_disabled_label'))) 5 | ->insert($view->fieldsetSwitch('DiskCache', 'enabled', $view::FIELDSET_EXPANDABLE)->setAttribute('template', $T('Webvirt_label')) 6 | ->insert($view->textInput('DiskCacheSize')->setAttribute('label', $T('DiskCacheSize_label')) 7 | ) 8 | ->insert($view->textInput('MinObjSize')->setAttribute('label', $T('MinObjSize_label')) 9 | ) 10 | ->insert($view->textInput('MaxObjSize')->setAttribute('label', $T('MaxObjSize_label')) 11 | ) 12 | ); 13 | 14 | echo '
'; 15 | echo $view->buttonList($view::BUTTON_SUBMIT | $view::BUTTON_HELP) 16 | ->insert($view->button('Clear_cache', $view::BUTTON_SUBMIT)->setAttribute('label', $T('ClearCache_label'))); 17 | -------------------------------------------------------------------------------- /root/etc/e-smith/templates/etc/squid/squid.conf/20acl_00_localnet: -------------------------------------------------------------------------------- 1 | { 2 | use esmith::NetworksDB; 3 | 4 | my $ndb = esmith::NetworksDB->open_ro(); 5 | my @localAccess = $ndb->local_access_spec(); 6 | $OUT .="# Allow access from green and trusted networks.\n"; 7 | foreach my $net (@localAccess) { 8 | next unless ($net ne "127.0.0.1"); 9 | my @tmp = split('/',$net); 10 | $net = esmith::util::computeLocalNetworkShortSpec($tmp[0],$tmp[1]); 11 | $OUT.="acl localnet src $net\n"; 12 | $OUT.="acl localnet_dst src $net\n"; 13 | } 14 | foreach ( $ndb->blue() ) { 15 | my $ip = $_->prop('ipaddr') || next; 16 | my $mask = $_->prop('netmask') || next; 17 | $OUT .="# Allow access from blue: ".$_->key."\n"; 18 | my $net = esmith::util::computeLocalNetworkShortSpec($ip,$mask); 19 | $OUT.="acl blue src $net\n"; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /root/etc/e-smith/templates/etc/squid/squid.conf/30http_access_50_auth: -------------------------------------------------------------------------------- 1 | { 2 | use esmith::NetworksDB; 3 | my $ndb = esmith::NetworksDB->open_ro(); 4 | my $green_mode = $squid{'GreenMode'} || "manual"; 5 | my $blue_mode = $squid{'BlueMode'} || "manual"; 6 | 7 | if ($green_mode eq 'authenticated') { 8 | $OUT.="# Authentication required on green and trusted networks\n"; 9 | $OUT.="http_access allow localnet authenticated\n"; 10 | } else { 11 | $OUT.="# No authentication on green and trusted networks\n"; 12 | $OUT.="http_access allow localnet\n"; 13 | } 14 | 15 | if (defined($ndb->blue())) { 16 | if ($blue_mode eq 'authenticated') { 17 | $OUT.="# Authentication required on blue\n"; 18 | $OUT.="http_access allow blue authenticated\n"; 19 | } else { 20 | $OUT.="# No authentication on blue\n"; 21 | $OUT.="http_access allow blue\n"; 22 | } 23 | } 24 | 25 | } 26 | 27 | -------------------------------------------------------------------------------- /root/etc/e-smith/templates/etc/squid/squid.conf/50proxy: -------------------------------------------------------------------------------- 1 | { 2 | my $parent = $squid{'ParentProxy'} || ""; 3 | my $global_host = $proxy{host} || ''; 4 | my $global_port = $proxy{port} || '3128'; 5 | my $global_user = $proxy{user} || ''; 6 | my $global_pass = $proxy{password} || ''; 7 | 8 | if ($parent eq '' && $global_host eq ''){ 9 | return ''; 10 | } 11 | 12 | $OUT.="\n# Parent proxy \n"; 13 | 14 | if ($parent eq '') 15 | { 16 | $OUT.="cache_peer ".$global_host." parent ".$global_port." 0 no-query no-digest"; 17 | if ($global_user ne '' && $global_pass ne ''){ 18 | $OUT.=' login='.$global_user.':'.$global_pass; 19 | } 20 | $OUT.="\n"; 21 | } else { 22 | my @tmp = split(':',$parent); 23 | if (!defined($tmp[1])) { 24 | $tmp[1] = "3128" 25 | } 26 | $OUT.="cache_peer ".$tmp[0]." parent ".$tmp[1]." 0 no-query no-digest\n"; 27 | } 28 | $OUT.="never_direct allow all\n"; 29 | } 30 | -------------------------------------------------------------------------------- /root/usr/share/nethesis/NethServer/Language/en/NethServer_Module_Proxy_Squid.php: -------------------------------------------------------------------------------- 1 | 14 | EVARS=" 15 | -e DEST_ID 16 | -e TRAVIS_BRANCH 17 | -e TRAVIS_BUILD_ID 18 | -e TRAVIS_PULL_REQUEST_BRANCH 19 | -e TRAVIS_PULL_REQUEST 20 | -e TRAVIS_REPO_SLUG 21 | -e TRAVIS_TAG 22 | -e NSVER 23 | -e VERSIONS_PACK 24 | -e STAGES_PACK 25 | -e UPLOAD_DEST 26 | " 27 | 28 | script: > 29 | docker run -ti --name makerpms ${EVARS} 30 | --hostname b${TRAVIS_BUILD_NUMBER}.nethserver.org 31 | --volume $PWD:/srv/makerpms/src:ro ${DOCKER_IMAGE} makerpms-travis -s *.spec 32 | && docker commit makerpms nethserver/build 33 | && docker run -ti ${EVARS} 34 | -e SECRET 35 | -e SECRET_URL 36 | -e AUTOBUILD_SECRET 37 | -e AUTOBUILD_SECRET_URL 38 | nethserver/build uploadrpms-travis 39 | -------------------------------------------------------------------------------- /root/etc/e-smith/templates/etc/squid/squid.conf/40cache: -------------------------------------------------------------------------------- 1 | { 2 | my $mem = $squid{'MemCacheSize'} || '256'; 3 | $OUT.="cache_mem $mem MB\n"; 4 | my $status = $squid{'DiskCache'} || 'enabled'; 5 | my $min = $squid{'MinObjSize'} || '0'; 6 | my $max = $squid{'MaxObjSize'} || '4096'; 7 | my $size = $squid{'DiskCacheSize'} || '100'; 8 | if ($status eq 'enabled') { 9 | $OUT.="\n# Enable disk cache\n"; 10 | $OUT.="minimum_object_size $min KB\n"; 11 | $OUT.="maximum_object_size $max KB\n"; 12 | $OUT.="cache_dir aufs /var/spool/squid $size 16 256\n"; 13 | } 14 | } 15 | 16 | # Leave coredumps in the first cache dir 17 | coredump_dir /var/spool/squid 18 | 19 | # 20 | # Add any of your own refresh_pattern entries above these. 21 | # 22 | refresh_pattern ^ftp: 1440 20% 10080 23 | refresh_pattern ^gopher: 1440 0% 1440 24 | refresh_pattern -i (/cgi-bin/|\?) 0 0% 0 25 | refresh_pattern . 0 20% 4320 26 | refresh_pattern ([^.]+.|)(download|(windows|)update|).(microsoft.|)com/.*\.(cab|exe|msi|msp) 4320 100% 43200 reload-into-ims 27 | -------------------------------------------------------------------------------- /root/etc/e-smith/events/actions/nethserver-squid-check-cache: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # Copyright (C) 2013 Nethesis S.r.l. 5 | # http://www.nethesis.it - support@nethesis.it 6 | # 7 | # This script is part of NethServer. 8 | # 9 | # NethServer is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, 12 | # or any later version. 13 | # 14 | # NethServer is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with NethServer. If not, see . 21 | # 22 | CACHE_STATUS=`/sbin/e-smith/config getprop squid DiskCache` 23 | 24 | if [ "$CACHE_STATUS" = "enabled" ]; then 25 | if [ ! -f "/var/spool/squid/swap.state" ]; then 26 | service squid status >/dev/null && service squid stop 27 | squid -z -F -N 28 | fi 29 | fi 30 | 31 | exit 0 32 | -------------------------------------------------------------------------------- /root/etc/e-smith/events/actions/nethserver-squid-ipset: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # Copyright (C) 2017 Nethesis S.r.l. 5 | # http://www.nethesis.it - nethserver@nethesis.it 6 | # 7 | # This script is part of NethServer. 8 | # 9 | # NethServer is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, 12 | # or any later version. 13 | # 14 | # NethServer is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with NethServer. If not, see COPYING. 21 | # 22 | 23 | # Manage ipset for squid bypass 24 | 25 | NAME=squid-bypass 26 | TIMEOUT=43200 # 12 hours 27 | 28 | ipset list $NAME 2>/dev/null 29 | 30 | # Create the ipset if not exists 31 | if [ $? -gt 0 ]; then 32 | ipset create $NAME iphash timeout $TIMEOUT 33 | else 34 | # otherwise flush it 35 | ipset flush $NAME 36 | fi 37 | 38 | -------------------------------------------------------------------------------- /root/etc/e-smith/events/actions/nethserver-squid-clear-cache: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # Copyright (C) 2013 Nethesis S.r.l. 5 | # http://www.nethesis.it - support@nethesis.it 6 | # 7 | # This script is part of NethServer. 8 | # 9 | # NethServer is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, 12 | # or any later version. 13 | # 14 | # NethServer is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with NethServer. If not, see . 21 | # 22 | SQUID_STATUS=`/sbin/e-smith/config getprop squid status` 23 | 24 | service squid status >/dev/null && service squid stop 25 | mkdir /var/spool/squid.old 2>/dev/null 26 | mv /var/spool/squid/* /var/spool/squid.old/ 27 | if [ "$SQUID_STATUS" = "enabled" ]; then 28 | squid -z -F -N 29 | service squid start 30 | fi 31 | rm -rf /var/spool/squid.old/ 32 | 33 | exit 0 34 | -------------------------------------------------------------------------------- /root/etc/e-smith/templates/etc/squid/squid.conf/20acl_10_auth: -------------------------------------------------------------------------------- 1 | { 2 | use esmith::NetworksDB; 3 | use NethServer::SSSD; 4 | my $ndb = esmith::NetworksDB->open_ro(); 5 | my $green_mode = $squid{'GreenMode'} || "manual"; 6 | my $blue_mode = $squid{'BlueMode'} || "manual"; 7 | my $sssd = new NethServer::SSSD(); 8 | if ($green_mode eq 'authenticated' || (defined($ndb->blue()) && $blue_mode eq 'authenticated')) { 9 | $OUT .= "# Authentication required\n\n"; 10 | 11 | if ($sssd->isAD()) { 12 | $OUT .= "\n# GSSAPI auth in ADS mode\n"; 13 | $OUT .= "auth_param negotiate program /usr/lib64/squid/negotiate_kerberos_auth -i\n"; 14 | $OUT .= "auth_param negotiate children 10\n"; 15 | $OUT .= "auth_param negotiate keep_alive on\n"; 16 | } 17 | 18 | $OUT .= "\n# BASIC PAM auth (fallback) \n"; 19 | $OUT .= "auth_param basic program /usr/lib64/squid/basic_pam_auth\n"; 20 | $OUT .= "auth_param basic children 5\n"; 21 | $OUT .= "auth_param basic realm $DomainName\n"; 22 | $OUT .= "auth_param basic credentialsttl 1 hours\n"; 23 | $OUT .= "auth_param basic casesensitive on\n"; 24 | 25 | 26 | $OUT.="acl authenticated proxy_auth REQUIRED\n"; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /.tx/config: -------------------------------------------------------------------------------- 1 | [main] 2 | host = https://www.transifex.com 3 | 4 | [nethserver.Proxy] 5 | source_file = root/usr/share/nethesis/NethServer/Language/en/NethServer_Module_Proxy.php 6 | source_lang = en 7 | type = PHP_ALT_ARRAY 8 | 9 | 10 | [nethserver.Proxy_BypassDst] 11 | source_file = root/usr/share/nethesis/NethServer/Language/en/NethServer_Module_Proxy_BypassDst.php 12 | source_lang = en 13 | type = PHP_ALT_ARRAY 14 | 15 | 16 | [nethserver.Proxy_Squid] 17 | source_file = root/usr/share/nethesis/NethServer/Language/en/NethServer_Module_Proxy_Squid.php 18 | source_lang = en 19 | type = PHP_ALT_ARRAY 20 | 21 | 22 | [nethserver.Proxy_BypassSrc] 23 | source_file = root/usr/share/nethesis/NethServer/Language/en/NethServer_Module_Proxy_BypassSrc.php 24 | source_lang = en 25 | type = PHP_ALT_ARRAY 26 | 27 | [nethserver.Proxy_BypassDomains] 28 | source_file = root/usr/share/nethesis/NethServer/Language/en/NethServer_Module_Proxy_BypassDomains.php 29 | source_lang = en 30 | type = PHP_ALT_ARRAY 31 | 32 | [nethserver.Proxy_Rules] 33 | source_file = root/usr/share/nethesis/NethServer/Language/en/NethServer_Module_Proxy_Rules.php 34 | source_lang = en 35 | type = PHP_ALT_ARRAY 36 | 37 | [nethserver.Proxy_Config] 38 | source_file = root/usr/share/nethesis/NethServer/Language/en/NethServer_Module_Proxy_Config.php 39 | source_lang = en 40 | type = PHP_ALT_ARRAY 41 | 42 | 43 | -------------------------------------------------------------------------------- /root/usr/share/nethesis/NethServer/Template/Proxy/Squid.php: -------------------------------------------------------------------------------- 1 | fieldset('GreenMode')->setAttribute('template', $T('GreenMode_label')) 4 | ->insert($view->radioButton('GreenMode', 'manual')) 5 | ->insert($view->radioButton('GreenMode', 'authenticated')) 6 | ->insert($view->radioButton('GreenMode', 'transparent')) 7 | ->insert($view->radioButton('GreenMode', 'transparent_ssl')); 8 | 9 | $blue_modes = $view->fieldset('BlueMode')->setAttribute('template', $T('BlueMode_label')) 10 | ->insert($view->radioButton('BlueMode', 'manual')) 11 | ->insert($view->radioButton('BlueMode', 'authenticated')) 12 | ->insert($view->radioButton('BlueMode', 'transparent')) 13 | ->insert($view->radioButton('BlueMode', 'transparent_ssl')); 14 | 15 | 16 | echo $view->fieldsetSwitch('status', 'enabled', $view::FIELDSETSWITCH_CHECKBOX) 17 | ->setAttribute('template', $T('Squid_status')) 18 | ->setAttribute('uncheckedValue', 'disabled') 19 | ->insert($green_modes) 20 | ->insert($blue_modes) 21 | ->insert($view->checkbox('PortBlock', 'enabled')->setAttribute('uncheckedValue', 'disabled')); 22 | 23 | echo $view->fieldset('', $view::FIELDSET_EXPANDABLE)->setAttribute('template', $T('ProxyAdvanced_label')) 24 | ->insert($view->textInput('ParentProxy')->setAttribute('placeholder','192.168.0.1:8080')); 25 | 26 | echo $view->buttonList($view::BUTTON_SUBMIT | $view::BUTTON_HELP); 27 | -------------------------------------------------------------------------------- /root/etc/e-smith/templates/etc/squid/squid.conf/40ports: -------------------------------------------------------------------------------- 1 | { 2 | use esmith::NetworksDB; 3 | my $ndb = esmith::NetworksDB->open_ro(); 4 | my $green_mode = $squid{'GreenMode'} || "manual"; 5 | my $blue_mode = $squid{'BlueMode'} || "manual"; 6 | 7 | $OUT.="\n# Always enable manual proxy\n"; 8 | $OUT.="http_port 3128\n"; 9 | 10 | if ($green_mode =~ /transparent/ || (defined($ndb->blue()) && $blue_mode =~ /transparent/)) { 11 | $OUT.="\n# Enable transparent proxy\n"; 12 | $OUT.="http_port 3129 transparent\n"; 13 | } 14 | if ($green_mode eq 'transparent_ssl' || (defined($ndb->blue()) && $blue_mode eq 'transparent_ssl')) { 15 | $OUT.="\n# Enable SSL transparent proxy 16 | https_port 3130 intercept ssl-bump generate-host-certificates=off cert=/etc/pki/tls/certs/NSRV.crt key=/etc/pki/tls/private/NSRV.key sslflags=NO_DEFAULT_CA options=NO_SSLv2,NO_SSLv3,No_Compression dynamic_cert_mem_cache_size=128KB 17 | "; 18 | } 19 | } 20 | 21 | acl https_proto proto https 22 | always_direct allow https_proto 23 | ssl_bump none localhost 24 | sslproxy_options NO_SSLv2,NO_SSLv3,No_Compression 25 | sslproxy_cipher ALL:!SSLv2:!ADH:!DSS:!MD5:!EXP:!DES:!PSK:!SRP:!RC4:!IDEA:!SEED:!aNULL:!eNULL 26 | # TLS/SSL bumping definitions 27 | acl tls_s1_connect at_step SslBump1 28 | acl tls_s2_client_hello at_step SslBump2 29 | acl tls_s3_server_hello at_step SslBump3 30 | # TLS/SSL bumping steps 31 | ssl_bump peek tls_s1_connect all 32 | ssl_bump splice all 33 | # peek at TLS/SSL connect data 34 | # splice: no active bumping 35 | -------------------------------------------------------------------------------- /root/usr/share/nethesis/NethServer/Module/Proxy.php: -------------------------------------------------------------------------------- 1 | . 21 | */ 22 | 23 | /** 24 | * Proxy configuration page with plugin behaviour 25 | * First tab is always present and has plugin behaviour. All other tabs can be plugins. 26 | */ 27 | class Proxy extends \Nethgui\Controller\TabsController 28 | { 29 | 30 | protected function initializeAttributes(\Nethgui\Module\ModuleAttributesInterface $base) 31 | { 32 | return \Nethgui\Module\SimpleModuleAttributesProvider::extendModuleAttributes($base, 'Gateway'); 33 | } 34 | 35 | public function initialize() 36 | { 37 | parent::initialize(); 38 | $this->loadChildrenDirectory(); 39 | $this->sortChildren(array($this,"sortPlugin")); 40 | } 41 | 42 | public function sortPlugin($a, $b) 43 | { 44 | if ($a->sortId == $b->sortId) { 45 | return 0; 46 | } else if ($a->sortId < $b->sortId) { 47 | return -1; 48 | } else { 49 | return 1; 50 | } 51 | } 52 | 53 | } 54 | 55 | -------------------------------------------------------------------------------- /root/usr/share/nethesis/NethServer/Module/Proxy/Config.php: -------------------------------------------------------------------------------- 1 | . 21 | */ 22 | 23 | use Nethgui\System\PlatformInterface as Validate; 24 | 25 | /** 26 | * Configure squid behaviour 27 | * 28 | * @author Edoardo Spadoni 29 | */ 30 | class Config extends \Nethgui\Controller\AbstractController 31 | { 32 | 33 | public $sortId = 40; 34 | 35 | protected function initializeAttributes(\Nethgui\Module\ModuleAttributesInterface $base) 36 | { 37 | return \Nethgui\Module\SimpleModuleAttributesProvider::extendModuleAttributes($base, 'Configuration', 80); 38 | } 39 | 40 | // Declare all parameters 41 | public function initialize() 42 | { 43 | parent::initialize(); 44 | 45 | $this->declareParameter('DiskCache', Validate::SERVICESTATUS, array('configuration', 'squid', 'DiskCache')); 46 | $this->declareParameter('DiskCacheSize', Validate::NONNEGATIVE_INTEGER, array('configuration', 'squid', 'DiskCacheSize')); 47 | $this->declareParameter('MinObjSize', Validate::NONNEGATIVE_INTEGER, array('configuration', 'squid', 'MinObjSize')); 48 | $this->declareParameter('MaxObjSize', Validate::NONNEGATIVE_INTEGER, array('configuration', 'squid', 'MaxObjSize')); 49 | } 50 | 51 | public function process() 52 | { 53 | parent::process(); 54 | 55 | if ($this->getRequest()->hasParameter('Clear_cache')) { 56 | // Signal nethserver-squid-clear-cache 57 | $this->getPlatform()->signalEvent('nethserver-squid-clear-cache &'); 58 | } 59 | } 60 | 61 | protected function onParametersSaved($changes) 62 | { 63 | $this->getPlatform()->signalEvent('nethserver-squid-save &'); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /root/usr/share/nethesis/NethServer/Module/Proxy/BypassDomains.php: -------------------------------------------------------------------------------- 1 | . 21 | */ 22 | 23 | use Nethgui\System\PlatformInterface as Validate; 24 | 25 | /** 26 | * Configure squid byapss domains 27 | * 28 | */ 29 | class BypassDomains extends \Nethgui\Controller\AbstractController 30 | { 31 | 32 | public $sortId = 20; 33 | 34 | 35 | // Declare all parameters 36 | public function initialize() 37 | { 38 | parent::initialize(); 39 | 40 | $this->declareParameter('BypassDomains', Validate::ANYTHING, array('configuration', 'squid', 'BypassDomains')); 41 | } 42 | 43 | public function readBypassDomains($v) 44 | { 45 | return implode("\n", explode(",", $v)); 46 | } 47 | 48 | public function writeBypassDomains($p) 49 | { 50 | return array(implode(',', array_filter(preg_split("/[,\s]+/", $p)))); 51 | } 52 | 53 | public function validate(\Nethgui\Controller\ValidationReportInterface $report) 54 | { 55 | parent::validate($report); 56 | if (!$this->getRequest()->isMutation()) { 57 | return; 58 | } 59 | 60 | $hostnameValidator = $this->createValidator(Validate::HOSTNAME_FQDN); 61 | $domains = array_filter(preg_split('/[,\s]+/', $this->parameters['BypassDomains'])); 62 | foreach ($domains as $domain){ 63 | if( ! $hostnameValidator->evaluate($domain)) { 64 | $report->addValidationErrorMessage($this, 'BypassDomains', 'valid_bypass', array($domain)); 65 | } 66 | } 67 | } 68 | 69 | protected function onParametersSaved($changes) 70 | { 71 | $this->getPlatform()->signalEvent('nethserver-squid-save &'); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /root/etc/e-smith/templates/var/www/html/wpad.dat/70proxyMode: -------------------------------------------------------------------------------- 1 | { 2 | use esmith::NetworksDB; 3 | use esmith::util; 4 | my $status = $squid{status} || 'disabled'; 5 | 6 | $ndb = esmith::NetworksDB->open_ro or warn("Could not open NetworksDB"); 7 | my $phost = "PROXY proxy.$DomainName:3128"; 8 | my $adJoin = 0; 9 | if ( ($smb{'status'} || 'disabled') eq 'enabled' and ($smb{'ServerRole'} || '') eq 'ADS' ) { 10 | $adJoin = 1; 11 | } 12 | 13 | 14 | if ($status eq 'disabled') { 15 | return ''; 16 | } 17 | 18 | if ($squid{'GreenMode'} eq 'transparent' || $squid{'GreenMode'} eq 'transparent_ssl') { 19 | foreach my $n ($ndb->green()) { 20 | my ($net, $bcast) = esmith::util::computeNetworkAndBroadcast($n->prop('ipaddr'), $n->prop('netmask')); 21 | $OUT.= "\n // ".$n->key.":$net green ".$squid{'GreenMode'}."\n"; 22 | $OUT.= ' if (isInNet(myIpAddress(), "'.$net.'", "'.$n->prop('netmask').'"))'."\n"; 23 | $OUT.= ' return "DIRECT";'. "\n"; 24 | } 25 | } 26 | 27 | if ($squid{'BlueMode'} eq 'transparent' || $squid{'BlueMode'} eq 'transparent_ssl') { 28 | foreach my $n ($ndb->blue()) { 29 | my ($net, $bcast) = esmith::util::computeNetworkAndBroadcast($n->prop('ipaddr'), $n->prop('netmask')); 30 | $OUT.= "\n // ".$n->key.":$net blue ".$squid{'BlueMode'}."\n"; 31 | $OUT.= ' if (isInNet(myIpAddress(), "'.$net.'", "'.$n->prop('netmask').'"))'."\n"; 32 | $OUT.= ' return "DIRECT";'. "\n"; 33 | } 34 | } 35 | 36 | if ($squid{'GreenMode'} eq 'authenticated' || $squid{'GreenMode'} eq 'manual') { 37 | foreach my $n ($ndb->green()) { 38 | my $target = "PROXY ".$n->prop('ipaddr').":3128"; 39 | if ($adJoin) { 40 | $target = $phost; 41 | } 42 | my ($net, $bcast) = esmith::util::computeNetworkAndBroadcast($n->prop('ipaddr'), $n->prop('netmask')); 43 | $OUT.= "\n // ".$n->key.":$net green ".$squid{'GreenMode'}."\n"; 44 | $OUT.= ' if (isInNet(myIpAddress(), "'.$net.'", "'.$n->prop('netmask').'"))'."\n"; 45 | $OUT.= " return \"$target\";\n"; 46 | } 47 | } 48 | 49 | if ($squid{'BlueMode'} eq 'authenticated' || $squid{'BlueMode'} eq 'manual') { 50 | foreach my $n ($ndb->blue()) { 51 | my $target = "PROXY ".$n->prop('ipaddr').":3128"; 52 | if ($adJoin) { 53 | $target = $phost; 54 | } 55 | my ($net, $bcast) = esmith::util::computeNetworkAndBroadcast($n->prop('ipaddr'), $n->prop('netmask')); 56 | $OUT.= "\n // ".$n->key.":$net blue ".$squid{'BlueMode'}."\n"; 57 | $OUT.= ' if (isInNet(myIpAddress(), "'.$net.'", "'.$n->prop('netmask').'"))'."\n"; 58 | $OUT.= " return \"$target\";\n"; 59 | } 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /root/etc/e-smith/templates/var/www/html/wpad.dat/60proxyBypass: -------------------------------------------------------------------------------- 1 | { 2 | use esmith::ConfigDB; 3 | use esmith::util; 4 | use NethServer::Firewall; 5 | use NetAddr::IP; 6 | use Socket 'inet_aton'; 7 | my $status = $squid{status} || 'disabled'; 8 | 9 | $db = esmith::ConfigDB->open_ro('fwrules') or warn("Could not open fwrules db"); 10 | $fw = new NethServer::Firewall(); 11 | my $phost = "PROXY proxy.$DomainName:3128"; 12 | 13 | if ($status eq 'disabled') { 14 | return ''; 15 | } 16 | 17 | foreach ($db->get_all_by_prop('type' => 'bypass-dst')) { 18 | next if ($_->prop('status') eq 'disabled'); 19 | my $h = $_->prop('Host') || next; 20 | my $address = $fw->getAddress($h); 21 | $OUT .= " // Bypass destination: ".$_->key.": $h\n"; 22 | if ($h =~ /cidr/) { 23 | $c = NetAddr::IP->new($address); 24 | $OUT .= ' if (isInNet(host, "'.$c->addr().'","'.$c->mask().'"))'; 25 | $OUT .= "\n return \"DIRECT\";\n"; 26 | } elsif ($h =~ /host-group/) { 27 | foreach my $h (split(/,/,$address)) { 28 | $OUT .= ' if (isInNet(host,"'.$h.'", "255.255.255.255"))'; 29 | $OUT .= "\n return \"DIRECT\";\n"; 30 | } 31 | } elsif ($h =~ /host/) { 32 | $OUT .= ' if (isInNet(host,"'.$address.'", "255.255.255.255"))'; 33 | $OUT .= "\n return \"DIRECT\";\n"; 34 | } else { 35 | next; 36 | } 37 | $OUT .= "\n"; 38 | } 39 | 40 | 41 | foreach ($db->get_all_by_prop('type' => 'bypass-src')) { 42 | next if ($_->prop('status') eq 'disabled'); 43 | my $h = $_->prop('Host') || next; 44 | my $address = $fw->getAddress($h); 45 | $OUT .= " // Bypass source: ".$_->key.": $h\n"; 46 | if ($h =~ /cidr/) { 47 | $c = NetAddr::IP->new($address); 48 | $OUT .= ' if (isInNet(myIpAddress(), "'.$c->addr().'","'.$c->mask().'"))'; 49 | $OUT .= "\n return \"DIRECT\";\n"; 50 | } elsif ($h =~ /host-group/) { 51 | foreach my $h (split(/,/,$address)) { 52 | $OUT .= ' if (myIpAddress() == "'.$h.'")'; 53 | $OUT .= "\n return \"DIRECT\";\n"; 54 | } 55 | } elsif ($h =~ /host/) { 56 | $OUT .= ' if (myIpAddress() == "'.$address.'")'; 57 | $OUT .= "\n return \"DIRECT\";\n"; 58 | } elsif ($h =~ /iprange/) { 59 | my ($start,$end) = split(/-/,$address); 60 | my @addresses = map { sprintf "%vi", pack "N", $_ } unpack("N",inet_aton($start)) .. unpack("N",inet_aton($end)); 61 | foreach my $h (@addresses) { 62 | $OUT .= ' if (myIpAddress() == "'.$h.'")'; 63 | $OUT .= "\n return \"DIRECT\";\n"; 64 | } 65 | 66 | } else { 67 | next; 68 | } 69 | $OUT .= "\n"; 70 | 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /root/etc/e-smith/templates/etc/squid/squid.conf/45marks: -------------------------------------------------------------------------------- 1 | 2 | # 3 | # 45marks 4 | # 5 | { 6 | use esmith::ConfigDB; 7 | use esmith::NetworksDB; 8 | use esmith::util; 9 | use NethServer::Firewall; 10 | 11 | my $fw = new NethServer::Firewall(); 12 | my $db = esmith::ConfigDB->open_ro('squid'); 13 | my $ndb = esmith::NetworksDB->open_ro(); 14 | our @providers = $fw->getProviders(); 15 | 16 | sub getProvider 17 | { 18 | my $needle = shift; 19 | 20 | foreach my $p (@providers) { 21 | if ($p->{'name'} eq $needle) { 22 | return $p; 23 | } 24 | } 25 | return undef; 26 | } 27 | 28 | 29 | foreach my $rule ($db->get_all_by_prop('type' => 'rule')) { 30 | my $src = $rule->prop('Src') || next; 31 | my $action = $rule->prop('Action') || next; 32 | my $status = $rule->prop('status') || 'disabled'; 33 | next if ($status eq 'disabled'); 34 | my $dst = $rule->prop('Dst') || ''; 35 | my $acl_dst_name = ''; 36 | my $src_addr = ''; 37 | if ($dst) { 38 | $dst =~ s/,/ \./g; 39 | $acl_dst_name = "dst_mark_".$rule->key; 40 | } 41 | my $acl_src_name = "src_mark_".$rule->key; 42 | if ($src =~ /^role;(.*)/) { 43 | foreach my $interface ($ndb->get_all_by_prop('role' => $1)) { 44 | my $ipaddr = $interface->prop('ipaddr') || next; 45 | my $mask = $interface->prop('netmask') || next; 46 | $src_addr .= " ".esmith::util::computeLocalNetworkShortSpec($ipaddr, $mask); 47 | } 48 | } else { 49 | $src_addr = $fw->getAddress($src,1); 50 | } 51 | 52 | # Supported objects: host, cidr, zone, iprange 53 | if ($src !~ /^(host|cidr|zone|iprange|role)/ || !$src_addr) { 54 | next; 55 | } 56 | $OUT .= "\n# Rule ".$rule->key.": src: $src action: $action dst: $dst\n"; 57 | $OUT .= "acl $acl_src_name src $src_addr\n"; 58 | if ($acl_dst_name) { 59 | $OUT .= "acl $acl_dst_name dstdomain .$dst\n"; 60 | } 61 | if ($action =~ /^priority;(.*)/) { 62 | # map low to 3 (low), map high to 2 (medium) 63 | # 1 (high) is reserved for system use 64 | $mask = (lc($1) eq 'low') ? "0x3": "0x2"; 65 | $OUT .= "tcp_outgoing_mark $mask $acl_src_name $acl_dst_name\n"; 66 | } elsif ($action =~ /^provider;(.*)/) { 67 | my $p = getProvider($1); 68 | my $mask = $p->{'mask'} || next; 69 | $OUT .= "tcp_outgoing_mark $mask $acl_src_name $acl_dst_name\n"; 70 | } elsif ($action =~ /^force;(.*)/) { 71 | my $p = getProvider($1); 72 | my $interface = $ndb->get($p->{'interface'}) || next; 73 | my $ipaddr = $interface->prop('ipaddr') || next; 74 | $OUT .= "tcp_outgoing_address $ipaddr $acl_src_name $acl_dst_name\n"; 75 | } else { 76 | next; 77 | } 78 | 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /root/usr/share/nethesis/NethServer/Module/Proxy/BypassDst.php: -------------------------------------------------------------------------------- 1 | . 21 | */ 22 | 23 | use Nethgui\System\PlatformInterface as Validate; 24 | 25 | /** 26 | * Bypass transparent proxy 27 | */ 28 | class BypassDst extends \Nethgui\Controller\TableController 29 | { 30 | public $sortId = 30; 31 | 32 | public function initialize() 33 | { 34 | $columns = array( 35 | 'Key', 36 | 'Host', 37 | 'Description', 38 | 'Actions', 39 | ); 40 | 41 | $parameterSchema = array( 42 | array('name', Validate::USERNAME, \Nethgui\Controller\Table\Modify::KEY), 43 | array('Description', Validate::ANYTHING, \Nethgui\Controller\Table\Modify::FIELD), 44 | ); 45 | 46 | $this 47 | ->setTableAdapter($this->getPlatform()->getTableAdapter('fwrules', 'bypass-dst')) 48 | ->setColumns($columns) 49 | ->addRowAction(new \NethServer\Module\Proxy\BypassDst\Modify('update')) 50 | ->addRowAction(new \NethServer\Module\Proxy\BypassDst\Modify('delete')) 51 | ->addTableAction(new \NethServer\Module\Proxy\BypassDst\Modify('create')) 52 | ->addTableAction(new \Nethgui\Controller\Table\Help('Help')) 53 | ; 54 | 55 | parent::initialize(); 56 | } 57 | 58 | private function formatObject(\Nethgui\View\ViewInterface $view, $val, $default='any_label') { 59 | if (!$val) { 60 | return $view->translate($default); 61 | } 62 | $tmp = explode(';',$val); 63 | return $view->translate($tmp[0].'_label').": ".$tmp[1]; 64 | } 65 | 66 | public function prepareViewForColumnKey(\Nethgui\Controller\Table\Read $action, \Nethgui\View\ViewInterface $view, $key, $values, &$rowMetadata) 67 | { 68 | if (!isset($values['status']) || ($values['status'] == 'disabled')) { 69 | $rowMetadata['rowCssClass'] = trim($rowMetadata['rowCssClass'] . ' user-locked'); 70 | } 71 | return strval($key); 72 | } 73 | 74 | public function prepareViewForColumnHost(\Nethgui\Controller\Table\Read $action, \Nethgui\View\ViewInterface $view, $key, $values, &$rowMetadata) 75 | { 76 | if (!isset($values['Host'])) { 77 | return ''; 78 | } 79 | return $this->formatObject($view, $values['Host']); 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /root/usr/share/nethesis/NethServer/Module/Proxy/BypassSrc.php: -------------------------------------------------------------------------------- 1 | . 21 | */ 22 | 23 | use Nethgui\System\PlatformInterface as Validate; 24 | 25 | /** 26 | * Bypass transparent proxy 27 | */ 28 | class BypassSrc extends \Nethgui\Controller\TableController 29 | { 30 | public $sortId = 30; 31 | 32 | public function initialize() 33 | { 34 | $columns = array( 35 | 'Key', 36 | 'Host', 37 | 'Description', 38 | 'Actions', 39 | ); 40 | 41 | $parameterSchema = array( 42 | array('name', Validate::USERNAME, \Nethgui\Controller\Table\Modify::KEY), 43 | array('Description', Validate::ANYTHING, \Nethgui\Controller\Table\Modify::FIELD), 44 | ); 45 | 46 | $this 47 | ->setTableAdapter($this->getPlatform()->getTableAdapter('fwrules', 'bypass-src')) 48 | ->setColumns($columns) 49 | ->addRowAction(new \NethServer\Module\Proxy\BypassSrc\Modify('update')) 50 | ->addRowAction(new \NethServer\Module\Proxy\BypassSrc\Modify('delete')) 51 | ->addTableAction(new \NethServer\Module\Proxy\BypassSrc\Modify('create')) 52 | ->addTableAction(new \Nethgui\Controller\Table\Help('Help')) 53 | ; 54 | 55 | parent::initialize(); 56 | } 57 | 58 | private function formatObject(\Nethgui\View\ViewInterface $view, $val, $default='any_label') { 59 | if (!$val) { 60 | return $view->translate($default); 61 | } 62 | $tmp = explode(';',$val); 63 | return $view->translate($tmp[0].'_label').": ".$tmp[1]; 64 | } 65 | 66 | public function prepareViewForColumnKey(\Nethgui\Controller\Table\Read $action, \Nethgui\View\ViewInterface $view, $key, $values, &$rowMetadata) 67 | { 68 | if (!isset($values['status']) || ($values['status'] == 'disabled')) { 69 | $rowMetadata['rowCssClass'] = trim($rowMetadata['rowCssClass'] . ' user-locked'); 70 | } 71 | return strval($key); 72 | } 73 | 74 | public function prepareViewForColumnHost(\Nethgui\Controller\Table\Read $action, \Nethgui\View\ViewInterface $view, $key, $values, &$rowMetadata) 75 | { 76 | if (!isset($values['Host'])) { 77 | return ''; 78 | } 79 | return $this->formatObject($view, $values['Host']); 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /root/usr/share/nethesis/NethServer/Module/Proxy/Rules.php: -------------------------------------------------------------------------------- 1 | . 21 | */ 22 | 23 | use Nethgui\System\PlatformInterface as Validate; 24 | 25 | /** 26 | * Bypass transparent proxy 27 | */ 28 | class Rules extends \Nethgui\Controller\TableController 29 | { 30 | public $sortId = 40; 31 | 32 | public function initialize() 33 | { 34 | $columns = array( 35 | 'Key', 36 | 'Src', 37 | 'Action', 38 | 'Dst', 39 | 'Description', 40 | 'Actions', 41 | ); 42 | 43 | $this 44 | ->setTableAdapter($this->getPlatform()->getTableAdapter('squid', 'rule')) 45 | ->setColumns($columns) 46 | ->addRowAction(new \NethServer\Module\Proxy\Rules\Modify('update')) 47 | ->addRowAction(new \NethServer\Module\Proxy\Rules\Modify('delete')) 48 | ->addTableAction(new \NethServer\Module\Proxy\Rules\Modify('create')) 49 | ->addTableAction(new \Nethgui\Controller\Table\Help('Help')) 50 | ; 51 | 52 | parent::initialize(); 53 | } 54 | 55 | private function formatObject(\Nethgui\View\ViewInterface $view, $val, $default='any_label') { 56 | if (!$val) { 57 | return $view->translate($default); 58 | } 59 | $tmp = explode(';',$val); 60 | return $view->translate($tmp[0].'_label').": ".$tmp[1]; 61 | } 62 | 63 | public function prepareViewForColumnKey(\Nethgui\Controller\Table\Read $action, \Nethgui\View\ViewInterface $view, $key, $values, &$rowMetadata) 64 | { 65 | if (!isset($values['status']) || ($values['status'] == 'disabled')) { 66 | $rowMetadata['rowCssClass'] = trim($rowMetadata['rowCssClass'] . ' user-locked'); 67 | } 68 | return strval($key); 69 | } 70 | 71 | public function prepareViewForColumnSrc(\Nethgui\Controller\Table\Read $action, \Nethgui\View\ViewInterface $view, $key, $values, &$rowMetadata) 72 | { 73 | return $this->formatObject($view, $values['Src']); 74 | } 75 | 76 | public function prepareViewForColumnAction(\Nethgui\Controller\Table\Read $action, \Nethgui\View\ViewInterface $view, $key, $values, &$rowMetadata) 77 | { 78 | $tmp = explode(";",$values['Action']); 79 | if ($tmp[0] == 'priority') { 80 | return $view->translate($tmp[1] . '_label'). " " . $view->translate($tmp[0] . '_label'); 81 | } else { 82 | return $view->translate($tmp[0] . '_label'). " " . $view->translate($tmp[1]); 83 | } 84 | } 85 | 86 | 87 | } 88 | -------------------------------------------------------------------------------- /root/usr/share/nethesis/NethServer/Module/Proxy/Squid.php: -------------------------------------------------------------------------------- 1 | . 21 | */ 22 | 23 | use Nethgui\System\PlatformInterface as Validate; 24 | 25 | /** 26 | * Configure squid behaviour 27 | * 28 | * @author Giacomo Sanchietti 29 | */ 30 | class Squid extends \Nethgui\Controller\AbstractController 31 | { 32 | 33 | public $sortId = 10; 34 | 35 | public $modes = array('manual','authenticated','transparent','transparent_ssl'); 36 | 37 | // Declare all parameters 38 | public function initialize() 39 | { 40 | parent::initialize(); 41 | 42 | $this->declareParameter('status', Validate::SERVICESTATUS, array('configuration', 'squid', 'status')); 43 | $this->declareParameter('GreenMode', $this->createValidator()->memberOf($this->modes), array('configuration', 'squid', 'GreenMode')); 44 | $this->declareParameter('BlueMode', $this->createValidator()->memberOf($this->modes), array('configuration', 'squid', 'BlueMode')); 45 | $this->declareParameter('ParentProxy', Validate::ANYTHING, array('configuration', 'squid', 'ParentProxy')); 46 | $this->declareParameter('PortBlock', Validate::SERVICESTATUS, array('configuration', 'squid', 'PortBlock')); 47 | } 48 | 49 | public function validate(\Nethgui\Controller\ValidationReportInterface $report) 50 | { 51 | if ($this->getRequest()->isMutation()) { 52 | if ($this->parameters['ParentProxy']) { 53 | $parts = explode(':', $this->parameters['ParentProxy']); 54 | $vh = $this->createValidator(Validate::HOSTADDRESS); 55 | if ( ! $vh->evaluate($parts[0]) ) { 56 | $report->addValidationError($this, 'ParentProxy', $vh); 57 | } 58 | if (isset($parts[1])) { 59 | $vp = $this->createValidator(Validate::PORTNUMBER); 60 | if ( ! $vp->evaluate($parts[1]) ) { 61 | $report->addValidationError($this, 'ParentProxy', $vp); 62 | } 63 | } 64 | } 65 | } 66 | 67 | parent::validate($report); 68 | } 69 | 70 | public function prepareView(\Nethgui\View\ViewInterface $view) 71 | { 72 | parent::prepareView($view); 73 | $ips = array(); 74 | foreach ($this->getPlatform()->getDatabase('networks')->getAll() as $key => $values) { 75 | if (isset($values['role']) && $values['role'] == 'green') { 76 | $ips[] = $values['ipaddr']; 77 | } 78 | } 79 | $view['ips'] = $ips; 80 | } 81 | 82 | protected function onParametersSaved($changes) 83 | { 84 | $this->getPlatform()->signalEvent('nethserver-squid-save'); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /root/usr/share/nethesis/NethServer/Help/en/NethServer_Module_Proxy.rst: -------------------------------------------------------------------------------- 1 | ========= 2 | Web proxy 3 | ========= 4 | 5 | Configure the web proxy (Squid) and bypass rules. 6 | 7 | Proxy 8 | ===== 9 | 10 | The web proxy works to reduce bandwidth usage by caching 11 | the pages you visit. It can also enforce content filtering. 12 | 13 | Web proxy can be enabled only on green (local networks) and blue (guest networks) zones. 14 | 15 | Manual 16 | Squid will listen on port 3128. All client must be explicitly configured to use the proxy. 17 | 18 | Authenticated 19 | Each user will be forced to enter user name and password. 20 | Squid will listen on port 3128. All client must be explicitly configured to use the proxy. 21 | 22 | Transparent 23 | All HTTP traffic on port 80 will be redirect through the proxy. 24 | No client configuration is needed. 25 | 26 | Transparent with SSL 27 | All HTTP and HTTPS traffic on port 80 and 443 will be redirect through the proxy. 28 | No client configuration is needed. 29 | 30 | Block HTTP and HTTPS ports 31 | If enabled, clients will not be able to bypass the proxy. 32 | External sites on ports 80 and 443 will be reachable only using the proxy. 33 | 34 | Parent proxy 35 | Enter the IP address and port of the parent proxy. The correct syntax is 36 | IP_Address:port. 37 | *DO NOT* enter the IP address of this server. 38 | 39 | Domains without proxy 40 | ===================== 41 | 42 | List of domains bypassed when transparent proxy is enabled. 43 | 44 | Requirement: all clients must use this machine as DNS server. 45 | 46 | Domains 47 | List of domains, one per line. 48 | Each entry matches the domain itself and all sub-domains. 49 | 50 | Hosts without proxy 51 | =================== 52 | 53 | List of internal hosts allowed to bypass the transparent proxy and access 54 | Internet without being filtered. 55 | 56 | Name 57 | A unique name for the bypass rule. 58 | 59 | Enabled 60 | Enable or disable the bypass rule. 61 | 62 | Host 63 | Select a host between local machines and firewall objects. 64 | 65 | Description 66 | Custom description (optional). 67 | 68 | Sites without proxy 69 | =================== 70 | 71 | List of remote hosts that need to be accessed directly. 72 | It's useful for badly written sites which don't work through a proxy. 73 | 74 | Name 75 | A unique name for the bypass rule. 76 | 77 | Enabled 78 | Enable or disable the bypass rule. 79 | 80 | Host 81 | Select a host between remote hosts and firewall objects. 82 | 83 | Description 84 | Custom description (optional). 85 | 86 | Rules 87 | ===== 88 | 89 | Change the priority or the output WAN for traffic which goes through the proxy. 90 | 91 | Rule # 92 | Auto-generated identification number 93 | 94 | Enable rule 95 | If checked, the rule is enabled. 96 | 97 | Source 98 | Select a host, zone, IP range or CIDR between firewall objects. 99 | 100 | Action 101 | There 3 actions available: 102 | 103 | - *Force to *: force the traffic from :guilabel:`Source` to the selected 104 | provider. If the provider is down, the remote hosts will not be reachable 105 | from the selected source 106 | 107 | - *Route to *: divert the traffic from :guilabel:`Source` to the selected provider. 108 | If the provider is down, the traffic will be routed accordingly to the 109 | configured multi wan policy. 110 | 111 | - *Low priority*: lower the priority of the traffic from :guilabel:`Source` 112 | 113 | - *High priority*: raise the priority of the traffic from :guilabel:`Source` 114 | 115 | 116 | Destination domains 117 | Accept a list of domain names. 118 | If left blank, the rule applies to any contacted remote host, 119 | otherwise the rule applies only if involved domain is listed. 120 | 121 | Description 122 | Custom description (optional). 123 | 124 | Cache 125 | ===== 126 | Cache configuration of squid (enabled o disabled) by setting these parameters: 127 | 128 | Disk cache size 129 | Set (in MB) the size of cache 130 | 131 | Min object size 132 | Set (in kB) the minimum size of cache object. 133 | 134 | Max object size 135 | Set (in kB) the maximum size of cache object. 136 | -------------------------------------------------------------------------------- /root/usr/share/nethesis/NethServer/Module/Proxy/BypassDst/Modify.php: -------------------------------------------------------------------------------- 1 | . 21 | */ 22 | 23 | use Nethgui\System\PlatformInterface as Validate; 24 | 25 | /** 26 | * Configure transparent proxy bypass 27 | * 28 | * @author Giacomo Sanchietti 29 | */ 30 | class Modify extends \Nethgui\Controller\Table\Modify 31 | { 32 | private $hosts = array(); 33 | private $hostGroups = array(); 34 | private $cidrs = array(); 35 | 36 | private function prepareVars() 37 | { 38 | if (!$this->hosts) { 39 | foreach ($this->getPlatform()->getDatabase('hosts')->getAll() as $key => $values) { 40 | if ($values['type'] == 'remote' || $values['type'] == 'host') { 41 | $this->hosts[$key] = $values; 42 | } 43 | } 44 | } 45 | if (!$this->hostGroups) { 46 | $this->hostGroups = $this->getPlatform()->getDatabase('hosts')->getAll('host-group'); 47 | } 48 | if (!$this->cidrs) { 49 | $this->cidrs = $this->getPlatform()->getDatabase('hosts')->getAll('cidr'); 50 | } 51 | 52 | } 53 | 54 | // Declare all parameters 55 | public function initialize() 56 | { 57 | $this->prepareVars(); 58 | 59 | $parameterSchema = array( 60 | array('name', Validate::USERNAME, \Nethgui\Controller\Table\Modify::KEY), 61 | array('Host', Validate::ANYTHING, \Nethgui\Controller\Table\Modify::FIELD), 62 | array('status', Validate::SERVICESTATUS, \Nethgui\Controller\Table\Modify::FIELD), 63 | array('Description', Validate::ANYTHING, \Nethgui\Controller\Table\Modify::FIELD), 64 | ); 65 | 66 | $this->setSchema($parameterSchema); 67 | $this->setDefaultValue('status', 'enabled'); 68 | 69 | parent::initialize(); 70 | } 71 | 72 | private function keyExists($key) 73 | { 74 | $tmp = explode(';', $key); 75 | if ($tmp[0] == 'host' || $tmp[0] == 'host-group' || $tmp[0] == 'cidr') { 76 | $db = 'hosts'; 77 | } else { 78 | $db = 'proxy'; 79 | } 80 | 81 | return ($this->getPlatform()->getDatabase($db)->getType($tmp[1]) != ''); 82 | } 83 | 84 | public function validate(\Nethgui\Controller\ValidationReportInterface $report) 85 | { 86 | $keyExists = $this->keyExists('bypass;'.$this->parameters['name']); 87 | if ($this->getIdentifier() === 'create' && $keyExists) { 88 | $report->addValidationErrorMessage($this, 'name', 'key_exists_message'); 89 | } 90 | if ($this->getIdentifier() && $this->parameters['Host'] && !$this->keyExists($this->parameters['Host'])) { 91 | $report->addValidationErrorMessage($this, 'Host', 'key_doesnt_exists_message'); 92 | } 93 | parent::validate($report); 94 | } 95 | 96 | private function arrayToDatasource($array, $prefix) 97 | { 98 | $ret = array(); 99 | foreach($array as $key => $props) { 100 | $ret[] = array($prefix.';'.$key, $key); 101 | } 102 | return $ret; 103 | } 104 | 105 | public function prepareView(\Nethgui\View\ViewInterface $view) 106 | { 107 | parent::prepareView($view); 108 | if($this->getIdentifier() != 'delete') { 109 | $view->setTemplate('NethServer\Template\Proxy\BypassModify'); 110 | } else { 111 | $view->setTemplate('Nethgui\Template\Table\Delete'); 112 | } 113 | 114 | $this->prepareVars(); 115 | 116 | $h = $view->translate('Hosts_label'); 117 | $hg = $view->translate('HostGroups_label'); 118 | $ir = $view->translate('IpRanges_label'); 119 | $c = $view->translate('CIDRs_label'); 120 | $hosts = $this->arrayToDatasource($this->hosts,'host'); 121 | $groups = $this->arrayToDatasource($this->hostGroups,'host-group'); 122 | $cidrs = $this->arrayToDatasource($this->cidrs,'cidr'); 123 | $view['HostDatasource'] = array(array($hosts,$h),array($groups,$hg),array($cidrs,$c)); 124 | } 125 | 126 | protected function onParametersSaved($changes) 127 | { 128 | $this->getPlatform()->signalEvent('firewall-adjust &'); 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /createlinks: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | # 4 | # Copyright (C) 2013 Nethesis S.r.l. 5 | # http://www.nethesis.it - support@nethesis.it 6 | # 7 | # This script is part of NethServer. 8 | # 9 | # NethServer is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, 12 | # or any later version. 13 | # 14 | # NethServer is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with NethServer. If not, see . 21 | # 22 | 23 | use strict; 24 | use esmith::Build::CreateLinks qw(:all); 25 | 26 | #-------------------------------------------------- 27 | # actions for nethserver-squid-update event 28 | #-------------------------------------------------- 29 | 30 | my $event = "nethserver-squid-update"; 31 | 32 | event_actions($event, qw( 33 | initialize-default-databases 00 34 | nethserver-sssd-initkeytabs 20 35 | nethserver-squid-check-cache 30 36 | nethserver-squid-ipset 50 37 | )); 38 | 39 | templates2events("/etc/squid/squid.conf", $event); 40 | templates2events("/etc/squid/acls/no_cache.acl", $event); 41 | templates2events("/etc/dnsmasq.conf", $event); 42 | templates2events("/etc/hosts", $event); 43 | templates2events("/var/www/html/wpad.dat", $event); 44 | templates2events("/etc/sysconfig/squid", $event); 45 | templates2events("/etc/httpd/conf.d/wpad.conf", $event); 46 | templates2events("/etc/backup-config.d/nethserver-sssd.include", $event); 47 | event_services($event, 'squid' => 'restart'); 48 | event_services($event, 'httpd' => 'reload'); 49 | event_services($event, 'dnsmasq' => 'restart'); 50 | 51 | #-------------------------------------------------- 52 | # actions for nethserver-squid-save event 53 | #-------------------------------------------------- 54 | 55 | my $event = "nethserver-squid-save"; 56 | 57 | event_actions($event, qw( 58 | nethserver-squid-check-cache 20 59 | nethserver-sssd-initkeytabs 20 60 | nethserver-squid-ipset 50 61 | firewall-adjust 30 62 | )); 63 | 64 | templates2events("/etc/squid/squid.conf", $event); 65 | templates2events("/etc/squid/acls/no_cache.acl", $event); 66 | templates2events("/etc/dnsmasq.conf", $event); 67 | templates2events("/etc/hosts", $event); 68 | templates2events("/var/www/html/wpad.dat", $event); 69 | templates2events("/etc/sysconfig/squid", $event); 70 | templates2events("/etc/backup-config.d/nethserver-sssd.include", $event); 71 | event_services($event, 'squid' => 'restart'); 72 | event_services($event, 'httpd' => 'reload'); 73 | event_services($event, 'dnsmasq' => 'restart'); 74 | 75 | #-------------------------------------------------- 76 | # actions for nethserver-squid-clear-cache 77 | #-------------------------------------------------- 78 | my $event = "nethserver-squid-clear-cache"; 79 | 80 | event_actions($event, qw( 81 | nethserver-squid-clear-cache 20 82 | )); 83 | 84 | #-------------------------------------------------- 85 | # actions for interface-update 86 | #-------------------------------------------------- 87 | my $event = "interface-update"; 88 | 89 | templates2events("/etc/squid/squid.conf", $event); 90 | templates2events("/etc/httpd/conf.d/wpad.conf", $event); 91 | event_services($event, 'squid' => 'restart'); 92 | event_actions($event, "nethserver-squid-httpd-reload", 20); 93 | 94 | # 95 | # nethserver-samba-{save,update,adsjoin) events 96 | # 97 | foreach (qw( 98 | nethserver-samba-save 99 | nethserver-samba-update 100 | nethserver-samba-adsjoin 101 | )) { 102 | event_templates($_, qw( 103 | /etc/squid/squid.conf 104 | /etc/sysconfig/squid 105 | )); 106 | event_services($_, qw( 107 | squid restart 108 | )); 109 | } 110 | 111 | # 112 | # Invalidate credentials cache when user account state changes 113 | # 114 | foreach (qw( 115 | password-modify 116 | user-lock 117 | user-unlock 118 | )) { 119 | event_services($_, qw( 120 | squid reload 121 | )); 122 | } 123 | 124 | # 125 | # Update wpad on firewall objects change 126 | # 127 | foreach (qw( 128 | nethserver-firewall-base-save 129 | firewall-objects-modify 130 | )) { 131 | event_templates($_, qw( 132 | /var/www/html/wpad.dat 133 | )); 134 | } 135 | 136 | #---------------------------------------------------------------------- 137 | # Expand squid and restart when a global http/https proxy is configured 138 | #---------------------------------------------------------------------- 139 | 140 | templates2events("/etc/squid/squid.conf","proxy-modify"); 141 | event_services("proxy-modify", 'squid' => 'restart'); 142 | 143 | #-------------------------------------------------- 144 | # actions for trusted-networks-modify event 145 | #-------------------------------------------------- 146 | 147 | $event = "trusted-networks-modify"; 148 | event_templates($event, qw( 149 | /etc/squid/squid.conf 150 | )); 151 | event_services($event, qw( 152 | squid restart 153 | )); 154 | -------------------------------------------------------------------------------- /root/usr/share/nethesis/NethServer/Module/Proxy/BypassSrc/Modify.php: -------------------------------------------------------------------------------- 1 | . 21 | */ 22 | 23 | use Nethgui\System\PlatformInterface as Validate; 24 | 25 | /** 26 | * Configure transparent proxy bypass 27 | * 28 | * @author Giacomo Sanchietti 29 | */ 30 | class Modify extends \Nethgui\Controller\Table\Modify 31 | { 32 | private $hosts = array(); 33 | private $hostGroups = array(); 34 | private $ipRanges = array(); 35 | private $cidrs = array(); 36 | 37 | private function prepareVars() 38 | { 39 | if (!$this->hosts) { 40 | foreach ($this->getPlatform()->getDatabase('hosts')->getAll() as $key => $values) { 41 | if ($values['type'] == 'local' || $values['type'] == 'remote' || $values['type'] == 'host') { 42 | $this->hosts[$key] = $values; 43 | } 44 | } 45 | } 46 | if (!$this->hostGroups) { 47 | $this->hostGroups = $this->getPlatform()->getDatabase('hosts')->getAll('host-group'); 48 | } 49 | if (!$this->ipRanges) { 50 | $this->ipRanges = $this->getPlatform()->getDatabase('hosts')->getAll('iprange'); 51 | } 52 | if (!$this->cidrs) { 53 | $this->cidrs = $this->getPlatform()->getDatabase('hosts')->getAll('cidr'); 54 | } 55 | } 56 | 57 | // Declare all parameters 58 | public function initialize() 59 | { 60 | $this->prepareVars(); 61 | 62 | $parameterSchema = array( 63 | array('name', Validate::USERNAME, \Nethgui\Controller\Table\Modify::KEY), 64 | array('Host', Validate::ANYTHING, \Nethgui\Controller\Table\Modify::FIELD), 65 | array('status', Validate::SERVICESTATUS, \Nethgui\Controller\Table\Modify::FIELD), 66 | array('Description', Validate::ANYTHING, \Nethgui\Controller\Table\Modify::FIELD), 67 | ); 68 | 69 | $this->setSchema($parameterSchema); 70 | $this->setDefaultValue('status', 'enabled'); 71 | 72 | parent::initialize(); 73 | } 74 | 75 | private function keyExists($key) 76 | { 77 | $tmp = explode(';', $key); 78 | if ($tmp[0] == 'host' || $tmp[0] == 'host-group' || $tmp[0] == 'iprange' || $tmp[0] == 'cidr') { 79 | $db = 'hosts'; 80 | } else { 81 | $db = 'proxy'; 82 | } 83 | 84 | return ($this->getPlatform()->getDatabase($db)->getType($tmp[1]) != ''); 85 | } 86 | 87 | public function validate(\Nethgui\Controller\ValidationReportInterface $report) 88 | { 89 | $keyExists = $this->keyExists('bypass;'.$this->parameters['name']); 90 | if ($this->getIdentifier() === 'create' && $keyExists) { 91 | $report->addValidationErrorMessage($this, 'name', 'key_exists_message'); 92 | } 93 | if ($this->getIdentifier() && $this->parameters['Host'] && !$this->keyExists($this->parameters['Host'])) { 94 | $report->addValidationErrorMessage($this, 'Host', 'key_doesnt_exists_message'); 95 | } 96 | parent::validate($report); 97 | } 98 | 99 | private function arrayToDatasource($array, $prefix) 100 | { 101 | $ret = array(); 102 | foreach($array as $key => $props) { 103 | $ret[] = array($prefix.';'.$key, $key); 104 | } 105 | return $ret; 106 | } 107 | 108 | public function prepareView(\Nethgui\View\ViewInterface $view) 109 | { 110 | parent::prepareView($view); 111 | if($this->getIdentifier() != 'delete') { 112 | $view->setTemplate('NethServer\Template\Proxy\BypassModify'); 113 | } else { 114 | $view->setTemplate('Nethgui\Template\Table\Delete'); 115 | } 116 | $this->prepareVars(); 117 | 118 | $h = $view->translate('Hosts_label'); 119 | $hg = $view->translate('HostGroups_label'); 120 | $ir = $view->translate('IpRanges_label'); 121 | $c = $view->translate('CIDRs_label'); 122 | $hosts = $this->arrayToDatasource($this->hosts,'host'); 123 | $groups = $this->arrayToDatasource($this->hostGroups,'host-group'); 124 | $ranges = $this->arrayToDatasource($this->ipRanges,'iprange'); 125 | $cidrs = $this->arrayToDatasource($this->cidrs,'cidr'); 126 | $view['HostDatasource'] = array(array($hosts,$h),array($groups,$hg),array($ranges,$ir),array($cidrs,$c)); 127 | } 128 | 129 | protected function onParametersSaved($changes) 130 | { 131 | $this->getPlatform()->signalEvent('firewall-adjust &'); 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /root/etc/e-smith/templates/etc/shorewall/rules/90squid: -------------------------------------------------------------------------------- 1 | # 2 | # 90squid 3 | # 4 | { 5 | use esmith::NetworksDB; 6 | use esmith::ConfigDB; 7 | use NethServer::Firewall; 8 | my $fw = new NethServer::Firewall(); 9 | my $ndb = esmith::NetworksDB->open_ro(); 10 | my $pdb = esmith::ConfigDB->open_ro('fwrules'); 11 | my $status = $squid{'status'} || 'disabled'; 12 | my $green_mode = $squid{'GreenMode'} || 'manual'; 13 | my $blue_mode = $squid{'BlueMode'} || 'manual'; 14 | my $block = $squid{'PortBlock'} || 'disabled'; 15 | my $bypass_domain_list = $squid{'BypassDomains'} ? '+squid-bypass' : ''; 16 | 17 | my %zones; 18 | my @ips; 19 | my @interfaces; 20 | foreach my $i ($ndb->interfaces) { 21 | my $role = $i->prop('role') || ''; 22 | my $ip = $i->prop('ipaddr') || ''; 23 | my $bp = $i->prop('bootproto') || ''; 24 | if ($ip ne '') { 25 | push(@ips,$ip); 26 | } else { 27 | if ($role eq 'red' && $bp eq 'dhcp') { 28 | push(@interfaces, "&".$i->key); 29 | } 30 | } 31 | 32 | next if ($role eq '' || $role eq 'red' || $role eq 'slave' || $role eq 'bridged' || $role eq 'alias' || $role eq 'pppoe'); 33 | my $zone = substr($role, 0, 5); #truncate zone name to 5 chars 34 | if ($role eq 'green') { # rename green to loc 35 | $zone = 'loc'; 36 | } 37 | $zones{$zone} = ''; # avoid duplicate policies 38 | } 39 | 40 | 41 | if ($status eq 'enabled') { 42 | my @bypass_src = (); 43 | my $bypass_src_str = ''; 44 | my @bypass_dst = (); 45 | my $bypass_dst_str = ''; 46 | push(@bypass_dst, @interfaces); 47 | push(@bypass_dst, @ips); 48 | if ($bypass_domain_list ne '') { 49 | push(@bypass_dst, $bypass_domain_list); 50 | } 51 | 52 | if ( $green_mode =~ /transparent/ || (defined($ndb->blue()) && $blue_mode =~ /transparent/) ) { 53 | 54 | foreach ($pdb->get_all_by_prop(type => 'bypass-src')) { 55 | my $status = $_->prop('status') || 'disabled'; 56 | next if ($status eq 'disabled'); 57 | my $host = $_->prop('Host') || next; 58 | my $address = $fw->getAddress($host) || next; 59 | push(@bypass_src,$address); 60 | } 61 | foreach ($pdb->get_all_by_prop(type => 'bypass-dst')) { 62 | my $status = $_->prop('status') || 'disabled'; 63 | next if ($status eq 'disabled'); 64 | my $host = $_->prop('Host') || next; 65 | my $address = $fw->getAddress($host) || next; 66 | push(@bypass_dst,$address); 67 | } 68 | 69 | } 70 | if (scalar(@bypass_src)>0) { 71 | $bypass_src_str = ":!".join(',',@bypass_src); 72 | } 73 | if (scalar(@bypass_dst)>0) { 74 | $bypass_dst_str = "!".join(',',@bypass_dst); 75 | } 76 | 77 | if ($green_mode =~ /transparent/) { 78 | $OUT.="#\n# Squid: accept HTTP/S traffic from/to firewall and green\n#\n"; 79 | $OUT.="ACCEPT\t\$FW\tnet\ttcp\t80\n"; 80 | $OUT.="ACCEPT\tloc\t\$FW\ttcp\t80\n"; 81 | $OUT.="ACCEPT\tloc\t\$FW\ttcp\t443\n"; 82 | 83 | $OUT .="?COMMENT transparent proxy on green for port 80\n"; 84 | $OUT.="REDIRECT\tloc$bypass_src_str\t3129\ttcp\t80\t-\t$bypass_dst_str\n"; 85 | if ($green_mode =~ /ssl/) { 86 | $OUT .="?COMMENT transparent proxy on green for port 443\n"; 87 | $OUT.="REDIRECT\tloc$bypass_src_str\t3130\ttcp\t443\t-\t$bypass_dst_str\n"; 88 | } 89 | 90 | } 91 | if (defined($ndb->blue()) && $blue_mode =~ /transparent/) { 92 | $OUT.="#\n# Squid: accept HTTP/S traffic from/to firewall and blue\n#\n"; 93 | $OUT.="ACCEPT\t\$FW\tnet\ttcp\t80\n"; 94 | $OUT.="ACCEPT\tblue\t\$FW\ttcp\t80\n"; 95 | $OUT.="ACCEPT\tblue\t\$FW\ttcp\t443\n"; 96 | 97 | my $ports = $squid{'TCPPorts'} || ''; 98 | foreach( split(/,/,$ports) ) { 99 | $OUT.="ACCEPT\tblue\t\$FW\ttcp\t$_\n"; 100 | } 101 | 102 | 103 | $OUT .="?COMMENT transparent proxy on blue for port 80\n"; 104 | $OUT.="REDIRECT\tblue$bypass_src_str\t3129\ttcp\t80\t-\t$bypass_dst_str\n"; 105 | if ($blue_mode =~ /ssl/) { 106 | $OUT .="?COMMENT transparent proxy on blue for port 443\n"; 107 | $OUT.="REDIRECT\tblue$bypass_src_str\t3130\ttcp\t443\t-\t$bypass_dst_str\n"; 108 | } 109 | } 110 | } 111 | 112 | if ($status eq 'enabled' && $block eq 'enabled') { 113 | # generate rules for all zones 114 | foreach my $z (keys %zones) { 115 | if ($z ne 'orang') { 116 | $OUT .= "#\n# Block HTTP/HTTPS from $z to net\n#\n"; 117 | $OUT .="?COMMENT Proxy block HTTP/HTTPS ports\n"; 118 | $OUT .= "REJECT $z\t\tnet\ttcp\t80,443\n"; 119 | } 120 | } 121 | } 122 | 123 | if ($status eq 'enabled' && defined($ndb->blue())) { 124 | $OUT .= "\n#\n# Allow Squid access from blue\n#\n"; 125 | $OUT .="?COMMENT Allow Squid access from blue\n"; 126 | $OUT .= "ACCEPT\tblue\t\$FW\ttcp\t3128\n"; 127 | } 128 | 129 | } 130 | -------------------------------------------------------------------------------- /nethserver-squid.spec: -------------------------------------------------------------------------------- 1 | Summary: NethServer squid configuration 2 | Name: nethserver-squid 3 | Version: 1.7.1 4 | Release: 1%{?dist} 5 | License: GPL 6 | URL: %{url_prefix}/%{name} 7 | Source0: %{name}-%{version}.tar.gz 8 | BuildArch: noarch 9 | 10 | Requires: nethserver-firewall-base, nethserver-httpd 11 | Requires: squid >= 3.5.20 12 | Requires: nethserver-sssd 13 | 14 | BuildRequires: perl 15 | BuildRequires: nethserver-devtools 16 | 17 | %description 18 | NethServer squid configuration 19 | 20 | %prep 21 | %setup 22 | 23 | %build 24 | %{makedocs} 25 | perl createlinks 26 | 27 | %install 28 | rm -rf %{buildroot} 29 | (cd root; find . -depth -print | cpio -dump %{buildroot}) 30 | %{genfilelist} %{buildroot} > %{name}-%{version}-filelist 31 | echo "%doc COPYING" >> %{name}-%{version}-filelist 32 | 33 | %post 34 | 35 | %preun 36 | 37 | %files -f %{name}-%{version}-filelist 38 | %defattr(-,root,root) 39 | %dir %{_nseventsdir}/%{name}-update 40 | 41 | %changelog 42 | * Mon Jul 02 2018 Davide Principi - 1.7.1-1 43 | - Fix of keytab backup configuration expansion - NethServer/dev#5536 44 | 45 | * Tue Jul 18 2017 Davide Principi - 1.7.0-1 46 | - Web proxy: support divert and priority rules - NethServer/dev#5327 47 | 48 | * Thu Jun 01 2017 Giacomo Sanchietti - 1.6.0-1 49 | - Web proxy: support bypass by domains - NethServer/dev#5299 50 | 51 | * Thu Apr 20 2017 Davide Principi - 1.5.4-1 52 | - Squid: integrated authentication doesn't work - Bug NethServer/dev#5259 53 | - squid: trusted networks not enabled - Bug NethServer/dev#5261 54 | 55 | * Wed Feb 15 2017 Davide Principi - 1.5.3-1 56 | - Squid parent proxy can no be set to ADDRESS:PORT in UI - Bug NethServer/dev#5217 57 | 58 | * Mon Jan 16 2017 Giacomo Sanchietti - 1.5.2-1 59 | - Web-proxy is interfering with the samba fileserver - Bug NethServer/dev#5194 60 | 61 | * Tue Jan 03 2017 Giacomo Sanchietti - 1.5.1-1 62 | - Disable squid ssl certificate generation - NethServer/dev#5176 63 | 64 | * Thu Dec 15 2016 Giacomo Sanchietti - 1.5.0-1 65 | - Transparent HTTPS proxy - NethServer/dev#5169 66 | 67 | * Thu Jul 07 2016 Stefano Fancello - 1.4.0-1 68 | - First NS7 release 69 | 70 | * Tue Dec 01 2015 Giacomo Sanchietti - 1.3.11-1 71 | - Add CIDR subnets and ip ranges as hosts without proxy in Proxy - Enhancement #3323 [NethServer] 72 | - WPAD improvements - Enhancement #3266 [NethServer] 73 | - Entire Subnet and Ip Ranges Exclusion in Proxy - Enhancement #3226 [NethServer] 74 | 75 | * Tue Nov 10 2015 Giacomo Sanchietti - 1.3.10-1 76 | - Configure forward_max_tries for Squid - Bug #3288 [NethServer] 77 | - squid log file rotation - Enhancement #3290 [NethServer] 78 | 79 | * Mon Oct 12 2015 Giacomo Sanchietti - 1.3.9-1 80 | - New zones can't browse the net thorugh proxy - Bug #3275 [NethServer] 81 | - Web Proxy http port block - Bug #3268 [NethServer] 82 | 83 | * Tue Sep 29 2015 Davide Principi - 1.3.8-1 84 | - Make Italian language pack optional - Enhancement #3265 [NethServer] 85 | 86 | * Thu Aug 27 2015 Davide Principi - 1.3.7-1 87 | - Web proxy: rules error if port blocking enabled with pppoe - Bug #3240 [NethServer] 88 | 89 | * Mon Jun 22 2015 Davide Principi - 1.3.6-1 90 | - SquidGuard profiles not working when proxy authenticated with AD - Enhancement #3178 [NethServer] 91 | - Fixed nethserver-squid-conf on keytab re-initialization. Was Bug #2407 [NethServer] 92 | 93 | * Tue May 19 2015 Giacomo Sanchietti - 1.3.5-1 94 | - web proxy does not cache objects bigger than 4Mb - Bug #3144 [NethServer] 95 | 96 | * Tue Apr 21 2015 Giacomo Sanchietti - 1.3.4-1 97 | - Proxy http doesn't allow http traffic when set in SSL transparent mode - Bug #3128 [NethServer] 98 | 99 | * Thu Apr 09 2015 Giacomo Sanchietti - 1.3.3-1 100 | - Web proxy: add prop for squid SSL_ports - Enhancement #3106 [NethServer] 101 | - squid stop after restore if cache enabled - Bug #3105 [NethServer] 102 | - Web proxy: add property for Squid safe ports - Enhancement #3101 [NethServer] 103 | - Web proxy: exclude local sites when mode is transparent - Enhancement #3099 [NethServer] 104 | 105 | * Thu Mar 12 2015 Giacomo Sanchietti - 1.3.2-1 106 | - Can't access Squid from blue network when proxy is configured in manual or authenticated mode - Bug #3086 [NethServer] 107 | - HTTP and HTTPS port blocked even if proxy is disabled - Bug #3050 [NethServer] 108 | - Allow authentication if samba is configured in WS mode - Bug #2984 [NethServer] 109 | 110 | * Tue Mar 10 2015 Giacomo Sanchietti - 1.3.1-1 111 | - Web proxy: Active Directory authentication not working - Bug #2984 [NethServer] 112 | - squid cache management - Feature #2981 [NethServer] 113 | 114 | * Tue Jan 20 2015 Giacomo Sanchietti - 1.3.0-1.ns6 115 | - Transparent proxy: switch iplementation from TPROXY to REDIRECT - Enhancement #2967 [NethServer] 116 | - Proxy: intercept SSL connections (SSL transparent) - Enhancement #2977 [NethServer] 117 | - Adjust squid.conf for better performances - Enhancement #2973 [NethServer] 118 | - Web proxy: support blue zones - Enhancement #2964 [NethServer] 119 | - Add port 980 to safe/ssl ports on squid configuration - Enhancement #2905 [NethServer] 120 | - Web proxy: bypass rules based on destination and source - Feature #2503 [NethServer] 121 | - Enhance upstream proxy validator - Enhancement #2736 [NethServer] 122 | 123 | * Wed Aug 20 2014 Davide Principi - 1.2.0-1.ns6 124 | - Proxy: block ports 80 (http) and 443 (https) - Feature #2777 [NethServer] 125 | - Web proxy: refactor squid.conf template - Enhancement #2704 [NethServer] 126 | 127 | * Wed Feb 05 2014 Davide Principi - 1.1.1-1.ns6 128 | - NethCamp 2014 - Task #2618 [NethServer] 129 | - Kerberos keytab file is missing for new services - Bug #2407 [NethServer] 130 | - Squid GSSAPI/GSS-Negotiate (Kerberos) authentication - Feature #1987 [NethServer] 131 | - Update all inline help documentation - Task #1780 [NethServer] 132 | 133 | * Wed Dec 18 2013 Davide Principi - 1.1.0-1.ns6 134 | - Kerberos keytab file is missing for new services - Bug #2407 [NethServer] 135 | - Squid GSSAPI/GSS-Negotiate (Kerberos) authentication - Feature #1987 [NethServer] 136 | 137 | * Wed Oct 16 2013 Giacomo Sanchietti - 1.0.4-1.ns6 138 | - Add proxy bypass rules #2072 139 | - Allow web traffic when Squid mode is transparent and disabled #2111 140 | - Db defaults: remove Runlevels prop #2067 141 | 142 | * Fri Jul 26 2013 Giacomo Sanchietti - 1.0.3-1.ns6 143 | - Change /etc/squid.conf permissions #1959 144 | - Change wpad template fragment order in /etc/hosts #17 145 | 146 | * Fri Jul 19 2013 Giacomo Sanchietti - 1.0.2-1.ns6 147 | - Restart squid on nethserver-squid-save and nethserver-squid-update events #1733 148 | - Use perl setuid wrapper for pam authentitcation #1773 149 | - Add bypass rules for trasparent proxy (without web ui) #2072 150 | 151 | * Tue Jul 16 2013 Giacomo Sanchietti - 1.0.1-1.ns6 152 | - Add missing translations #1773 153 | 154 | * Thu Jun 20 2013 Giacomo Sanchietti - 1.0.0-1.ns6 155 | - First release with wpad support #1773 #17 156 | 157 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | ================ 2 | nethserver-squid 3 | ================ 4 | 5 | This package configure the well-known Squid web proxy. 6 | 7 | Squid rpms are from upstream. 8 | 9 | Configuration 10 | ============= 11 | 12 | All properties are saved in the ``squid`` key under the ``configuration`` database. 13 | 14 | Properties: 15 | 16 | * *BlueMode*: change Squid operation mode on blue networks. It has same values and defaults of ``GreenMode`` 17 | * *BypassDomains*: comma separeted list of domains bypassed when the proxy is set in transparent mode 18 | * *DiskCache*: disabled by default, if enabled it actives the disk caching system for squid 19 | * *DiskCacheSize*: maximum value of squid cache on disk 20 | * *GreenMode*: change Squid operation mode on green networks. 21 | Can be: ``manual``, ``authenticated``, ``transparent``, ``transparent_ssl``. Default is: ``manual`` 22 | * *KrbPrimaryList*: name for Kerberos keytab (used for Active Directory integration) 23 | * *KrbStatus*: if set to enabled a ticket credential cache file is kept valid by the hourly cron job (used for Active Directory integration) 24 | * *MaxObjSize*: objects larger than this setting will not be saved on disk. If speed is more desirable than saving bandwidth, this should be set to a low value 25 | * *MemCacheSize*: value of squid cache on memory 26 | * *MinObjSize*: can be left at 0 to cache everything, but may be raised if small objects are not desired in the cache. 27 | * *NoCache*: comma separated list of domains which will be not cached 28 | * *ParentProxy*: in the form host:port, if omitted port is default to 3128. Default is empty 29 | * *PortBlock*: if enabled, block port 80 and 443. Default is: ``disabled`` 30 | * *SafePorts*: comma separated list of ports thath can be accessed through the proxy. Listed ports will be added to the default list of safe and ssl ports 31 | 32 | Database example 33 | ---------------- 34 | 35 | Example: :: 36 | 37 | squid=service 38 | BlueMode=manual 39 | DiskCache=disabled 40 | DiskCacheSize=100 41 | GreenMode=transparent 42 | KrbPrimaryList=HTTP 43 | KrbStatus=enabled 44 | MaxObjSize=4096 45 | MemCacheSize=256 46 | MinObjSize=1 47 | NoCache=www.nethserver.org 48 | ParentProxy= 49 | PortBlock=disabled 50 | TCPPorts=3128,3129,3130 51 | access=private 52 | status=enabled 53 | 54 | 55 | Transparent mode 56 | ================ 57 | 58 | When the proxy is enabled in transparent mode, all traffic destined to the port 80 is redirect to the Squid (port 3129). 59 | This configuration requires Shorewall. 60 | 61 | SSL peek and splice 62 | ------------------- 63 | 64 | If the proxy is enabled in transparent SSL mode, also all traffic destined to port 443 is redirected to Squid (port 3130). 65 | The daemon does not inspect SSL traffic, but visited sites can be processed using the web filter. 66 | 67 | Known bugs 68 | ^^^^^^^^^^ 69 | 70 | You could find this kind of errors inside ``/var/log/squid/cache.log`` :: 71 | 72 | 2016/12/09 09:44:18 kid1| SECURITY ALERT: on URL: avatars0.githubusercontent.com:443 73 | 2016/12/09 09:44:18 kid1| SECURITY ALERT: Host header forgery detected on local=151.101.60.133:443 remote=192.168.5.22:40950 FD 166 flags=33 (local IP does not match any domain IP) 74 | 75 | In this case, when accessing github, the avatars won't be displayed by the browser, and you can find a "Timeout error" for the not loaded images. 76 | 77 | This kind of errors can't be fixed. See official documentation for workarounds: 78 | 79 | * http://wiki.squid-cache.org/KnowledgeBase/HostHeaderForgery2 80 | * http://lists.squid-cache.org/pipermail/squid-users/2016-September/012344.html 81 | 82 | Authenticated mode 83 | ================== 84 | 85 | Authentication schema depends on system configuration: 86 | 87 | * standard authentication for system users is done over LDAP 88 | * if Samba AD is installed, clients can use Kerberos (SPNEGO/GSSAPI) 89 | 90 | Bypasses 91 | ======== 92 | 93 | The implementation supports 3 kind of bypass: 94 | 95 | - source bypass 96 | - destination bypass 97 | - domains bypass 98 | 99 | Source and destination bypass 100 | ----------------------------- 101 | 102 | Bypass rules are saved inside the ``fwrules`` databases. 103 | A bypass can be of two types: 104 | 105 | * bypass-src: listed origin host are bypassed 106 | * bypass-dst: listed target host are bypassed 107 | 108 | Properties: 109 | * *Host*: a host object, like a remote or local host 110 | * *status*: can be ``enabled`` or ``disabled`` 111 | * *Description*: optional description 112 | 113 | 114 | Bypass example: :: 115 | 116 | boss=bypass-src 117 | Description=Boss without proxy 118 | Host=host;bosspc 119 | status=enabled 120 | 121 | Domains bypass 122 | --------------- 123 | 124 | All requests to domains listed inside the ``BypassDomains`` property will not 125 | be redirect to the transparent proxy. 126 | 127 | The implementation uses the ipset feature of Dnsmasq. 128 | Each time a listed domain is accessed from the client, Dnsmasq resolves the IP 129 | and add it to ``squid-bypass`` ipset. 130 | The ``squid-bypass`` ipset is then used as exception inside Shorewall REDIRECT rule. 131 | 132 | Notes: 133 | 134 | * all clients must use the server as DNS 135 | * Dnsmasq name resolution works for the listed domains and all sub-domains 136 | 137 | Cache 138 | ===== 139 | 140 | There is an *event* called ``nethserver-squid-clear-cache`` that empties the cache. 141 | 142 | Priority and divert rules 143 | ========================= 144 | 145 | The ``squid`` database contains multiple records of type ``rule``. 146 | 147 | Each rule has following properties: 148 | 149 | * ``key``: it's a numeric uniq id 150 | * ``Action``: 151 | 152 | * ``priority;low``: add low priority packet marker using ``tcp_outgoing_mark`` 153 | * ``priority;high``: add high priority packet marker using ``tcp_outgoing_mark`` 154 | * ``provider;``: add packet marker for provider ```` using ``tcp_outgoing_mark`` 155 | * ``force;``: force output traffic to ```` provider using ``tcp_outgoing_address`` 156 | 157 | * ``Description``: optional description 158 | * ``Dst``: comma-separeted list of domains, this is converted to a ``dstdomain`` ACL 159 | * ``Src``: firewall object, supported objects are: role, host, zone, ip range and cidr . This is converted to ``src`` ACL 160 | * ``status``: can be ``enabled`` or ``disabled`` 161 | 162 | Example: :: 163 | 164 | 1=rule 165 | Action=priority;low 166 | Description= 167 | Dst=yahoo.com 168 | Src=host;giacomo 169 | status=enabled 170 | 2=rule 171 | Action=provider;fast 172 | Description= 173 | Dst=nethserver.org,nethesis.it 174 | Src=host;birro 175 | status=enabled 176 | 3=rule 177 | Action=force;slow 178 | Description= 179 | Dst= 180 | Src=cidr;cidr1 181 | status=enabled 182 | 183 | 184 | WPAD 185 | ==== 186 | 187 | WPAD is located at :file:`/var/www/html/wpad.dat`. 188 | The web server is configured to allow the download only from trusted and blue networks, 189 | but be aware that you need to manually open the httpd port for blue networks (see :ref:`network_service_custom_access-section`). 190 | 191 | The WPAD returns: 192 | 193 | * DIRECT, if squid is disabled or the requesting client is inside a network where the proxy is configured in transparent mode 194 | * IP of corresponding network interface, if the requesting client is inside a network where the proxy is configured in manual or authenticated mode 195 | * proxy., if the server is joined to Active Directory and the requesting client is inside a 196 | network where the proxy is configured in manual or authenticated mode 197 | 198 | Also WPAD file includes all source and destination bypasses. 199 | 200 | Miscellaneous options 201 | ===================== 202 | 203 | The following options are always enabled: 204 | 205 | * buffered logs 206 | * SNMP support on port 3401 207 | -------------------------------------------------------------------------------- /root/usr/share/nethesis/NethServer/Module/Proxy/Rules/Modify.php: -------------------------------------------------------------------------------- 1 | . 21 | */ 22 | 23 | use Nethgui\System\PlatformInterface as Validate; 24 | 25 | /** 26 | * Configure transparent proxy bypass 27 | * 28 | * @author Giacomo Sanchietti 29 | */ 30 | class Modify extends \Nethgui\Controller\Table\Modify 31 | { 32 | private $hosts = array(); 33 | private $ipRanges = array(); 34 | private $cidrs = array(); 35 | private $zones = array(); 36 | private $roles = array(); 37 | private $actions = array(); 38 | private $objs = array(); 39 | 40 | private function prepareVars() 41 | { 42 | if (!$this->hosts) { 43 | foreach ($this->getPlatform()->getDatabase('hosts')->getAll() as $key => $values) { 44 | if ($values['type'] == 'local' || $values['type'] == 'host') { 45 | $this->hosts[$key] = $values; 46 | } 47 | } 48 | } 49 | if (!$this->ipRanges) { 50 | $this->ipRanges = $this->getPlatform()->getDatabase('hosts')->getAll('iprange'); 51 | } 52 | if (!$this->cidrs) { 53 | $this->cidrs = $this->getPlatform()->getDatabase('hosts')->getAll('cidr'); 54 | } 55 | if (!$this->zones) { 56 | $this->zones = $this->getPlatform()->getDatabase('networks')->getAll('zone'); 57 | } 58 | if (!$this->roles) { 59 | $tmp = array(); 60 | foreach($this->getPlatform()->getDatabase('networks')->getAll() as $key => $props) { 61 | if (isset($props['role']) && in_array($props['role'],array('green','orange','blue'))) { 62 | $tmp[$props['role']] = ''; 63 | } 64 | } 65 | $this->roles = array_keys($tmp); 66 | } 67 | 68 | if (!$this->actions) { 69 | foreach ($this->getPlatform()->getDatabase('networks')->getAll('provider') as $key => $props) { 70 | $i = $this->getPlatform()->getDatabase('networks')->getKey($props['interface']); 71 | if (isset($i['ipaddr']) && $i['ipaddr']) { # force traffic only for red with static IP 72 | $this->actions[] = 'force;'.$key; 73 | } 74 | $this->actions[] = 'provider;'.$key; 75 | } 76 | $this->actions[] = 'priority;low'; 77 | $this->actions[] = 'priority;high'; 78 | } 79 | if (!$this->objs) { 80 | foreach ($this->arrayToDatasource($this->hosts,'host') as $pair) { 81 | $this->objs[] = $pair[0]; 82 | } 83 | foreach ($this->arrayToDatasource($this->ipRanges,'iprange') as $pair) { 84 | $this->objs[] = $pair[0]; 85 | } 86 | foreach ($this->arrayToDatasource($this->cidrs,'cidr') as $pair) { 87 | $this->objs[] = $pair[0]; 88 | } 89 | foreach ($this->arrayToDatasource($this->zones,'zone') as $pair) { 90 | $this->objs[] = $pair[0]; 91 | } 92 | foreach ($this->roles as $role) { 93 | $this->objs[] = "role;".$role; 94 | } 95 | } 96 | } 97 | 98 | // Declare all parameters 99 | public function initialize() 100 | { 101 | $this->prepareVars(); 102 | 103 | $parameterSchema = array( 104 | array('id', $this->createValidator()->integer(), \Nethgui\Controller\Table\Modify::KEY), 105 | array('Src', $this->createValidator()->memberOf($this->objs), \Nethgui\Controller\Table\Modify::FIELD), 106 | array('Action', $this->createValidator()->memberOf($this->actions), \Nethgui\Controller\Table\Modify::FIELD), 107 | array('Dst', Validate::ANYTHING, \Nethgui\Controller\Table\Modify::FIELD), 108 | array('status', Validate::SERVICESTATUS, \Nethgui\Controller\Table\Modify::FIELD), 109 | array('Description', Validate::ANYTHING, \Nethgui\Controller\Table\Modify::FIELD), 110 | ); 111 | 112 | $this->setSchema($parameterSchema); 113 | $this->setDefaultValue('status', 'enabled'); 114 | 115 | parent::initialize(); 116 | } 117 | 118 | public function readDst($v) 119 | { 120 | return implode("\n", explode(",", $v)); 121 | } 122 | 123 | public function writeDst($p) 124 | { 125 | return array(implode(',', array_filter(preg_split("/[,\s]+/", $p)))); 126 | } 127 | 128 | private function nextKey() 129 | { 130 | $db = $this->getPlatform()->getDatabase('squid'); 131 | $max = max(array_keys($db->getAll('rule'))); 132 | return $max+1; 133 | } 134 | 135 | public function validate(\Nethgui\Controller\ValidationReportInterface $report) 136 | { 137 | $v_domain = $this->createValidator()->hostname(1); 138 | if($this->parameters['Dst'] && $this->getRequest()->isMutation()) { 139 | $domains = array_filter(preg_split('/[,\s]+/', $this->parameters['Dst'])); 140 | foreach ($domains as $d){ 141 | if( ! $v_domain->evaluate($d)) { 142 | $report->addValidationError($this, $d, $v_domain); 143 | } 144 | } 145 | } 146 | 147 | parent::validate($report); 148 | } 149 | 150 | private function arrayToDatasource($array, $prefix) 151 | { 152 | $ret = array(); 153 | foreach($array as $key => $props) { 154 | $ret[] = array($prefix.';'.$key, $key); 155 | } 156 | return $ret; 157 | } 158 | 159 | public function prepareView(\Nethgui\View\ViewInterface $view) 160 | { 161 | parent::prepareView($view); 162 | if($this->getIdentifier() != 'delete') { 163 | $view->setTemplate('NethServer\Template\Proxy\RulesModify'); 164 | } else { 165 | $view->setTemplate('Nethgui\Template\Table\Delete'); 166 | } 167 | $this->prepareVars(); 168 | 169 | if ($this->getIdentifier() == 'create') { 170 | $view['id'] = $this->nextKey(); 171 | } 172 | $h = $view->translate('Hosts_label'); 173 | $ir = $view->translate('IpRanges_label'); 174 | $c = $view->translate('CIDRs_label'); 175 | $z = $view->translate('Zones_label'); 176 | $hosts = $this->arrayToDatasource($this->hosts,'host'); 177 | $ranges = $this->arrayToDatasource($this->ipRanges,'iprange'); 178 | $cidrs = $this->arrayToDatasource($this->cidrs,'cidr'); 179 | $zones = $this->arrayToDatasource($this->zones,'zone'); 180 | foreach($this->roles as $role) { 181 | $zones[] = array('role;'.$role, $role); 182 | } 183 | $view['SrcDatasource'] = array(array($hosts,$h),array($ranges,$ir),array($cidrs,$c),array($zones,$z)); 184 | $view['ActionDatasource'] = array_map(function($fmt) use ($view) { 185 | $tmp = explode(";",$fmt); 186 | if ($tmp[0] == 'priority') { 187 | return array($fmt, $view->translate($tmp[1] . '_label'). " " . $view->translate($tmp[0] . '_label')); 188 | } else { 189 | return array($fmt, $view->translate($tmp[0] . '_label'). " " . $view->translate($tmp[1])); 190 | } 191 | }, $this->actions); 192 | 193 | } 194 | 195 | protected function onParametersSaved($changes) 196 | { 197 | $this->getPlatform()->signalEvent('nethserver-squid-save &'); 198 | } 199 | } 200 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------