Skip to content
This repository has been archived by the owner on May 2, 2019. It is now read-only.

Commit

Permalink
Merge pull request #150 from equalitie/next
Browse files Browse the repository at this point in the history
CENO v0.5.0
  • Loading branch information
misaakidis committed Nov 20, 2015
2 parents 29ccf7a + f1b55db commit 75cb6ba
Show file tree
Hide file tree
Showing 76 changed files with 1,759 additions and 1,832 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ npm install
CENOLANG=<language> npm start
```

where `<language>` is to be replaced with a language identifier such as
where `<language>` is to be replaced with a language identifier such as `en` or `fr`.

### CENOBRidge Freenet plugin

Expand Down
23 changes: 3 additions & 20 deletions ceno-box/build.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#! /bin/bash

# This script will create a CENO all-in-one box ready for distribution
# If the -p (plugins) flag is enabled, the bundle will include a build of CENO
# client, Freemail and WebOfTrust plugins with the latest local modifications.
#
# This CENOBOx bundle includes:
# * A Freenet node, preloaded with the WebOfTrust, Freemail and CENO plugins,
Expand Down Expand Up @@ -146,27 +144,12 @@ echo "Building CENO client and Backbone Freenet plugins"
cd ../ceno-freenet
ant dist > /dev/null
cp dist/CENO.jar $CENOBOXPATH/ceno-debug/
cp dist/CENOBackbone.jar $CENOBOXPATH/ceno-debug/
cp dist/CENOBridge.jar $CENOBOXPATH/ceno-debug/
cp dist/CENOBackbone.jar $CENOBOXPATH/ceno-backbone/
cp dist/CENOBridge.jar $CENOBOXPATH/ceno-bridge/
cd $CENOBOXPATH

echo "Building WebOfTrust plugin"
cd ceno-debug/plugin-WebOfTrust
ant dist > /dev/null
cp dist/WebOfTrust.jar $CENOBOXPATH/ceno-debug
cd $CENOBOXPATH

echo "Building Freemail plugin"
cd ceno-debug/plugin-Freemail
ant dist > /dev/null
cp dist/Freemail.jar $CENOBOXPATH/ceno-debug
cd $CENOBOXPATH

cp -r ceno-debug/{CENOBackbone.jar,WebOfTrust.jar,Freemail.jar} CENOBackbone/
cp -r ceno-debug/{CENOBridge.jar,WebOfTrust.jar,Freemail.jar} CENOBridge/

if [[ $PLUGINS == 1 ]]; then
cp -r ceno-debug/{CENO.jar,WebOfTrust.jar,Freemail.jar} CENOBox/
cp -r ceno-debug/CENO.jar CENOBox/
cp ceno-debug/freenet-client.ini CENOBox/freenet.ini
fi

Expand Down
2 changes: 1 addition & 1 deletion ceno-box/ceno-backbone/freenet.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is overwritten whenever Freenet shuts down, so only edit it when the node is not running.
fproxy.hasCompletedWizard=true
pluginmanager.loadplugin=UPnP;WebOfTrust.jar;Freemail.jar;CENOBackbone.jar
pluginmanager.loadplugin=UPnP;CENOBackbone.jar
node.opennet.enabled=true
node.storeSize=2147483648
node.inputBandwidthLimit=-1
Expand Down
2 changes: 2 additions & 0 deletions ceno-box/ceno-bridge/.CENO/bridge.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
insertURI=
requestURI=
isMasterBridge=true
isSignalBridge=true
2 changes: 1 addition & 1 deletion ceno-box/ceno-bridge/freenet.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is overwritten whenever Freenet shuts down, so only edit it when the node is not running.
fproxy.hasCompletedWizard=true
pluginmanager.loadplugin=UPnP;WebOfTrust;Freemail.jar;CENOBridge.jar
pluginmanager.loadplugin=UPnP;CENOBackbone.jar
node.opennet.enabled=true
node.storeSize=2147483648
node.inputBandwidthLimit=-1
Expand Down
2 changes: 1 addition & 1 deletion ceno-box/ceno-debug/freenet-client.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is overwritten whenever Freenet shuts down, so only edit it when the node is not running.
fproxy.hasCompletedWizard=true
pluginmanager.loadplugin=KeyUtils;ThawIndexBrowser;Library;UPnP;WebOfTrust.jar;Freemail.jar;CENO.jar
pluginmanager.loadplugin=KeyUtils;ThawIndexBrowser;Library;UPnP;CENO.jar
node.opennet.enabled=true
node.storeSize=1073741824
node.minDiskFreeLongTerm=1073741824
Expand Down
1 change: 0 additions & 1 deletion ceno-box/ceno-debug/plugin-Freemail

This file was deleted.

1 change: 0 additions & 1 deletion ceno-box/ceno-debug/plugin-WebOfTrust

This file was deleted.

Binary file removed ceno-box/ceno-freenet/WebOfTrust/WebOfTrust.db4o
Binary file not shown.

This file was deleted.

19 changes: 0 additions & 19 deletions ceno-box/ceno-freenet/freemail-wot/globalconfig

This file was deleted.

2 changes: 1 addition & 1 deletion ceno-box/ceno-freenet/freenet.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is overwritten whenever Freenet shuts down, so only edit it when the node is not running.
fproxy.hasCompletedWizard=true
pluginmanager.loadplugin=KeyUtils;ThawIndexBrowser;Library;UPnP;WebOfTrust;USK@gDDFEF5ZzqQBVdKzzZ94xupb14x8cMVu7HIwSIFAgds,IJiH6~EPNfx2tgd0nrFYnnG988PHBrHj~UTMN4zRDmA,AQACAAE/Freemail/-1/Freemail.jar;USK@kWKE67nhHNp6C-lgD5QtpL5qnIgmsnM6B5i7xxJGXIQ,UhZYJ2R6egIAjdMGAQbsjPcos1~CIJ~CbUKjpuUlwXA,AQACAAE/CENO-plugin/-1/CENO.jar
pluginmanager.loadplugin=KeyUtils;ThawIndexBrowser;Library;UPnP;USK@kWKE67nhHNp6C-lgD5QtpL5qnIgmsnM6B5i7xxJGXIQ,UhZYJ2R6egIAjdMGAQbsjPcos1~CIJ~CbUKjpuUlwXA,AQACAAE/CENO-plugin/-1/CENO.jar
node.opennet.enabled=true
node.storeSize=1073741824
node.minDiskFreeLongTerm=1073741824
Expand Down
36 changes: 17 additions & 19 deletions ceno-bridge/bshandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,23 @@ const RSS_READER_HEADER = 'x-rss-reader';

// The format of date-time printed in the logs. A formatted date looks like:
// Nov 04, 2015 03:02:14:116
const LOGGING_DATEFORMAT = ("mmm dd, yyyy HH:MM:ss:l")
const LOGGING_DATEFORMAT = 'mmm dd, yyyy HH:MM:ss:l';

/**
* Log a message to the console with the current date and time.
* @param {string} msg - The message to output
*/
function bs_log(msg) {
console.log(dateFormat(new Date(), LOGGING_DATEFORMAT) + ' [BUNDLE SERVER] ' + msg);
}

// POST to the RR to prompt it to accept a completed bundle.
/**
* POST to the RR to prompt it to accept a completed bundle.
* @param {object} config - The bundle server configuration, which includes info about the RR
* @param {object} data - The body of the request to send to the RR
* @param {bool} wasRewritten - Whether the request was rewritten from HTTPS to HTTP
* @param {function} cb - A callback to invoke to handle the results of the request
*/
function reportCompleteBundle(config, data, wasRewritten, cb) {
var headers = {};
headers[REWRITTEN_HEADER] = wasRewritten;
Expand Down Expand Up @@ -75,23 +85,6 @@ function requestFromReader(request) {
return typeof headerValue !== 'undefined' && headerValue === 'true';
}

/**
* An on-original-received handler to strip resources from a document by replacing
* attributes in particular tags with an empty string.
* @param {string} tag - The name of the tag to find (e.g. a)
* @param {string} attr - The attribute to replace the value of (e.g. href)
*/
function stripResource(tag, attr) {
return function (reqFn, originalDoc, url, callback) {
var diff = {};
b.htmlFinder(originalDoc, tag, attr)(function (value) {
console.log('Writing an empty diff for ' + value, 'tag =', tag, 'attr =', attr);
diff[value] = '';
});
callback(null, diff);
};
}

/**
* Create a bundler object that will use configured proxy settings to fetch a given URL and
* bundle the contents. If the request comes from the RSS reader, it will produce only the
Expand Down Expand Up @@ -148,6 +141,11 @@ function makeBundler(url, config, reqFromReader) {
return bundler;
}

/**
* Creates a request handler that is a closure over the bundle server's Configuration
* @param {object} config - The bundle server's configuration
* @return a handler callback for http.createServer
*/
function handler(config) {
return function (req, res) {
var disconnected = false; // A flag set when the request is closed.
Expand Down
4 changes: 3 additions & 1 deletion ceno-bridge/bundle-server.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
var fs = require('fs');
var path = require('path');
var http = require('http');

var bsHandlerMaker = require('./bshandler');
var _t = require('./translations');

const configFile = path.join('config', 'node.json');

// A default configuration to run the bundle server in case the expected configuration file
// cannot be found or loaded for some reason.
var defaultConfig = {
port: 3094,
requestReceiver: 'http://localhost:3093',
useProxy: false,
userAgent: 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36'
};

// Apply the default configuration for now.
var config = defaultConfig;

try {
Expand Down
2 changes: 1 addition & 1 deletion ceno-bridge/config/node.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"port": 3094,
"requestReceiver": "http://localhost:3093",
"requestReceiver": "http://localhost:3095",
"useProxy": false,
"proxyAddress": "http://localhost:8118",
"userAgent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36"
Expand Down
17 changes: 13 additions & 4 deletions ceno-client/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,36 @@ SOURCE_FILES="src/client.go \
src/config.go \
src/data.go \
src/portal.go \
src/articles.go \
src/resources.go"
src/articles.go"

echo "Formatting go files."
for file in `ls src/*.go`; do
go fmt $file;
go fmt $file;
done

echo ""
echo "Installing dependencies."
echo "goi18n"
go get -u github.com/nicksnyder/go-i18n/goi18n

echo ""
echo "Merging localization files."
cd translations
$GOPATH/bin/goi18n *.all.json *.untranslated.json
cd ..

echo ""
echo "Building feature and integration testing tools."
cd test
go build erroringlcs.go
echo " * erroringlcs - LCS that always serves an error for testing auto-refreshing."
cd ..

go build $SOURCE_FILES && echo "Compiled client successfully."
echo ""
go build $SOURCE_FILES
COMPILE_STATUS=$?
if [ $COMPILE_STATUS -eq 0 ]; then
echo "[SUCCESS] - Compiled CENO Client."
else
echo "[FAILURE] - Did not compile CENO Client."
fi
1 change: 1 addition & 0 deletions ceno-client/src/articles.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
* JSON files containing information about articles stored in the distributed cache (Freenet)
* are named like `json-files/<base64(feed's url)>.json`
* @param feedUrl - The URL of the RSS/Atom feed to retrieve information about articles from
* @return the path to the article of interest's respective JSON file on disk
*/
func articlesFilename(feedUrl string) string {
b64FeedUrl := base64.StdEncoding.EncodeToString([]byte(feedUrl))
Expand Down
10 changes: 8 additions & 2 deletions ceno-client/src/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ type Result struct {

/**
* Log the current time and a message
* @param {interface} msg - The message to be logged
* @param {interface{}} msg - The message or value to be logged
* @return the same message that is logged to console
*/
func log(msg interface{}) string {
t := strings.Replace(time.Now().Format("Jan 01, 2006 15:04:05.000"), ".", ":", 1)
Expand All @@ -59,6 +60,7 @@ func log(msg interface{}) string {
* Set a header on responses that indicates that the response was served by the CENO client.
* Useful for checking if the CENO Client is running via an HTTP request.
* @param {ResponseWriter} w - The ResponseWriter used to serve the current request's response.
* @return the modified response writer
*/
func WriteProxyHeader(w http.ResponseWriter) http.ResponseWriter {
w.Header().Add("X-Ceno-Proxy", "yxorP-oneC-X")
Expand Down Expand Up @@ -93,6 +95,7 @@ func pleaseWait(URL string, w http.ResponseWriter) {
/**
* Request that the LCS start a lookup process for a particular URL.
* @param {string} lookupURL - The URL to try to find in the distributed cache
* @return the result of the lookup with any error code and message or values retrieved
*/
func Lookup(lookupURL string) Result {
response, err := http.Get(BundleLookupURL(Configuration, lookupURL))
Expand Down Expand Up @@ -132,6 +135,7 @@ func Lookup(lookupURL string) Result {
* Request that the RS issue a request to create a new bundle.
* @param {string} lookupURL - The URL of the site to create a bundle for
* @param {bool} wasRewritten - True if the requested URL was rewritten from HTTPS to HTTP
* @return any error that occurs creating or issuing the request
*/
func requestNewBundle(lookupURL string, wasRewritten bool) error {
// We can ignore the content of the response since it is not used.
Expand All @@ -152,6 +156,7 @@ func requestNewBundle(lookupURL string, wasRewritten bool) error {
* Strip out the S in HTTPS from URLs provided to the CC via the /lookup path.
* Returns the written URL and a boolean indicating whether the downgrade was made.
* @param {string} URL - The decoded (from b64) URL being requested
* @return the new URL and a bool set to true if a rewrite of http->https occurred
*/
func stripHttps(URL string) (string, bool) {
if strings.Index(URL, "https") != 0 {
Expand Down Expand Up @@ -206,7 +211,7 @@ func directHandler(w http.ResponseWriter, r *http.Request) {
"URL": stripped,
}), ErrorState{"responseWriter": w, "request": r})
} else {
// Finally we can pass the modified request onto the proxy server.
// Finally we can pass the modified request onto the proxy handler.
r.URL = newURL
proxyHandler(w, r)
}
Expand All @@ -219,6 +224,7 @@ func directHandler(w http.ResponseWriter, r *http.Request) {
* @param {string} URL - The URL being requested
* @param {ResponseWriter} w - The object handling writing responses to the client
* @param {*Request} r - Information about the request
* @return true if the url is well-formed or else false
*/
func validateURL(URL string, w http.ResponseWriter, r *http.Request) bool {
isValid, err := regexp.MatchString(URL_REGEX, URL)
Expand Down
Loading

0 comments on commit 75cb6ba

Please sign in to comment.