@@ 855-892 (lines=38) @@ | ||
852 | * |
|
853 | * @return string |
|
854 | */ |
|
855 | protected function _vcl_sub_maintenance_allowed_ips() { |
|
856 | if (( ! $this->_getDebugIps()) || ! Mage::getStoreConfig('turpentine_vcl/maintenance/custom_vcl_synth')) { |
|
857 | return false; |
|
858 | } |
|
859 | ||
860 | switch (Mage::getStoreConfig('turpentine_varnish/servers/version')) { |
|
861 | case 4.0: |
|
862 | $tpl = <<<EOS |
|
863 | if (req.http.X-Forwarded-For) { |
|
864 | if (req.http.X-Forwarded-For !~ "{{debug_ips}}") { |
|
865 | return (synth(999, "Maintenance mode")); |
|
866 | } |
|
867 | } |
|
868 | else { |
|
869 | if (client.ip !~ debug_acl) { |
|
870 | return (synth(999, "Maintenance mode")); |
|
871 | } |
|
872 | } |
|
873 | ||
874 | EOS; |
|
875 | break; |
|
876 | default: |
|
877 | $tpl = <<<EOS |
|
878 | if (req.http.X-Forwarded-For) { |
|
879 | if(req.http.X-Forwarded-For !~ "{{debug_ips}}") { |
|
880 | error 503; |
|
881 | } |
|
882 | } else { |
|
883 | if (client.ip !~ debug_acl) { |
|
884 | error 503; |
|
885 | } |
|
886 | } |
|
887 | EOS; |
|
888 | } |
|
889 | ||
890 | return $this->_formatTemplate($tpl, array( |
|
891 | 'debug_ips' => Mage::getStoreConfig('dev/restrict/allow_ips') )); |
|
892 | } |
|
893 | ||
894 | /** |
|
895 | * Get the allowed IPs when in maintenance mode |
|
@@ 899-932 (lines=34) @@ | ||
896 | * |
|
897 | * @return string |
|
898 | */ |
|
899 | protected function _vcl_sub_synth() |
|
900 | { |
|
901 | if (( ! $this->_getDebugIps()) || ! Mage::getStoreConfig('turpentine_vcl/maintenance/custom_vcl_synth')) { |
|
902 | return false; |
|
903 | } |
|
904 | ||
905 | switch (Mage::getStoreConfig('turpentine_varnish/servers/version')) { |
|
906 | case 4.0: |
|
907 | $tpl = <<<EOS |
|
908 | sub vcl_synth { |
|
909 | if (resp.status == 999) { |
|
910 | set resp.status = 404; |
|
911 | set resp.http.Content-Type = "text/html; charset=utf-8"; |
|
912 | synthetic({"{{vcl_synth_content}}"}); |
|
913 | return (deliver); |
|
914 | } |
|
915 | return (deliver); |
|
916 | } |
|
917 | ||
918 | EOS; |
|
919 | break; |
|
920 | default: |
|
921 | $tpl = <<<EOS |
|
922 | sub vcl_error { |
|
923 | set obj.http.Content-Type = "text/html; charset=utf-8"; |
|
924 | synthetic {"{{vcl_synth_content}}"}; |
|
925 | return (deliver); |
|
926 | } |
|
927 | EOS; |
|
928 | } |
|
929 | ||
930 | return $this->_formatTemplate($tpl, array( |
|
931 | 'vcl_synth_content' => Mage::getStoreConfig('turpentine_vcl/maintenance/custom_vcl_synth'))); |
|
932 | } |
|
933 | ||
934 | ||
935 |