Skip to content

Commit

Permalink
autoconfig.pac can be used to browse .yacy-domains only
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6077 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
lotus committed Jun 15, 2009
1 parent 4e82585 commit aec3e79
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 2 deletions.
3 changes: 3 additions & 0 deletions defaults/yacy.init
Expand Up @@ -515,6 +515,9 @@ proxyIndexingRemote=false
proxyIndexingLocalText=true
proxyIndexingLocalMedia=true

# proxy usage only for .yacy-Domains for autoconfig
proxyYacyOnly=false

# From the 'IndexCreate' menu point you can also define a crawling start point.
# The crawling works the same way as the prefetch, but it is possible to
# assign a different crawling depth.
Expand Down
13 changes: 13 additions & 0 deletions htroot/ProxyIndexingMonitor_p.html
Expand Up @@ -18,6 +18,19 @@ <h2>Indexing with Proxy</h2>

<form action="ProxyIndexingMonitor_p.html" method="post" enctype="multipart/form-data">
<table border="0" cellpadding="5" cellspacing="1">
<tr class="TableCellDark">
<td colspan="3"><strong>Proxy Auto Config:</strong>
this controls the proxy auto configuration script for browsers at http://localhost:8080/autoconfig.pac
</td>
</tr>
<tr valign="top" class="TableCellLight">
<td><label for="proxyYacyOnly">.yacy-domains only</label></td>
<td><input type="checkbox" id="proxyYacyOnly" name="proxyYacyOnly"#(proxyYacyOnly)#:: checked="checked"#(/proxyYacyOnly)# /></td>
<td>
whether the proxy should only be used for .yacy-Domains
</td>
</tr>

<tr class="TableCellDark">
<td colspan="3"><strong>Proxy pre-fetch setting:</strong>
this is an automated html page loading procedure that takes actual proxy-requested
Expand Down
4 changes: 4 additions & 0 deletions htroot/ProxyIndexingMonitor_p.java
Expand Up @@ -63,6 +63,8 @@ public static serverObjects respond(final httpRequestHeader header, final server

if (post.containsKey("proxyprofileset")) try {
// read values and put them in global settings
final boolean proxyYaCyOnly = post.containsKey("proxyYacyOnly");
env.setConfig(plasmaSwitchboardConstants.PROXY_YACY_ONLY, (proxyYaCyOnly) ? "true" : "false");
int newProxyPrefetchDepth = post.getInt("proxyPrefetchDepth", 0);
if (newProxyPrefetchDepth < 0) newProxyPrefetchDepth = 0;
if (newProxyPrefetchDepth > 20) newProxyPrefetchDepth = 20; // self protection ?
Expand Down Expand Up @@ -147,6 +149,8 @@ public static serverObjects respond(final httpRequestHeader header, final server
}
}

final boolean yacyonly = env.getConfigBool(plasmaSwitchboardConstants.PROXY_YACY_ONLY, false);
prop.put("proxyYacyOnly", yacyonly ? "1" : "0");
prop.put("proxyPrefetchDepth", env.getConfigLong("proxyPrefetchDepth", 0));
prop.put("proxyStoreHTCacheChecked", env.getConfig("proxyStoreHTCache", "").equals("true") ? "1" : "0");
prop.put("proxyIndexingRemote", env.getConfig("proxyIndexingRemote", "").equals("true") ? "1" : "0");
Expand Down
8 changes: 6 additions & 2 deletions htroot/autoconfig.java
Expand Up @@ -25,6 +25,7 @@
//if the shell's current path is HTROOT

import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboardConstants;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;

Expand All @@ -43,6 +44,8 @@ public static serverObjects respond(final httpRequestHeader header, final server

final serverObjects prop = new serverObjects();

final boolean yacyonly = env.getConfigBool(plasmaSwitchboardConstants.PROXY_YACY_ONLY, false);

// getting the http host header
final String hostSocket = header.get(httpRequestHeader.CONNECTION_PROP_HOST);

Expand All @@ -54,8 +57,9 @@ public static serverObjects respond(final httpRequestHeader header, final server
host = hostSocket.substring(0, pos);
}

prop.put("host", host);
prop.put("port", port);
prop.put("yacy", yacyonly ? "0" : "1");
prop.put("yacy_host", host);
prop.put("yacy_port", port);

return prop;
}
Expand Down
8 changes: 8 additions & 0 deletions htroot/autoconfig.pac
@@ -1,4 +1,11 @@
function FindProxyForURL(url,host) {
#(yacy)#
// .yacy only
if(shExpMatch(host,"*.yacy")) {
return "PROXY #[host]#:#[port]#, DIRECT";
}
return "DIRECT";
::
// http only
if (!(url.substring(0, 5).toLowerCase() == "http:")) {
return "DIRECT";
Expand All @@ -21,4 +28,5 @@ function FindProxyForURL(url,host) {

// then
return "PROXY #[host]#:#[port]#, DIRECT";
#(/yacy)#
}
1 change: 1 addition & 0 deletions source/de/anomic/plasma/plasmaSwitchboardConstants.java
Expand Up @@ -277,6 +277,7 @@ public final class plasmaSwitchboardConstants {
* @see plasmaSwitchboard#PROXY_CACHE_LAYOUT_TREE
* @see plasmaSwitchboard#PROXY_CACHE_LAYOUT_HASH
*/
public static final String PROXY_YACY_ONLY = "proxyYacyOnly";

//////////////////////////////////////////////////////////////////////////////////////////////
// Cluster settings
Expand Down

0 comments on commit aec3e79

Please sign in to comment.