Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
e09a550
fix put file upload with existing file
kzahel Mar 4, 2017
6d7b130
fix connection close issue with curl
kzahel Jun 6, 2017
72c5991
Add support for index.xhtml and index.xhtm
Jul 20, 2017
90319a0
Make index.xhtm(l) prefered over index.htm(l)
Jul 20, 2017
343b4e9
Merge pull request #103 from PorygonZRocks/patch-1
kzahel Jul 20, 2017
56b1bd6
fix CORS headers OPTIONS preflight for PUT
kzahel Sep 22, 2017
1534fe8
make .finish() always wait for write buffer empty
kzahel Nov 4, 2017
61cef78
Automatic folder creation during file upload
oleg-khymchenko-kh Jan 21, 2018
7034bff
Merge pull request #126 from oleg-khymchenko-kh/master
kzahel Jan 21, 2018
a473a3c
Fix directory listing view in Firefox
scheinercc Mar 17, 2018
6db00cf
Merge pull request #137 from scheinercc/patch-1
kzahel Mar 17, 2018
5426e15
Modifying CSS to fit Edge/IE rendering, this has no effect on chrome
lon3wolf Apr 8, 2018
c81f66b
Update directory-listing-template.html
lon3wolf Apr 8, 2018
29ee56c
Merge pull request #140 from lon3wolf/master
kzahel Apr 8, 2018
2962435
Simplify minimize.sh script
sdegutis May 2, 2018
dad73b5
Merge pull request #142 from sdegutis/patch-1
kzahel May 2, 2018
8140b45
Support receiving spaces in POST form fields
danopia Jun 9, 2018
fb5e095
Support zero-length POST bodies
danopia Jul 4, 2018
f7bdc4c
Merge pull request #149 from stardustapp/master
kzahel Jul 9, 2018
0329c4e
Added mime type for mjs.
ahmetkizilay Nov 11, 2018
e49e15a
Merge pull request #161 from ahmetkizilay/mjs-mimetype
kzahel Nov 12, 2018
5202439
add bug report as comment
kzahel Dec 26, 2018
b74a4b4
fix typo
kzahel Jan 15, 2019
cb300b1
add mime type for .wasm
Feb 25, 2019
91190d2
Merge pull request #168 from chhschou/master
kzahel Feb 25, 2019
556ad9a
react ui rewrite
kzahel Dec 27, 2019
f64314d
do some styling
kzahel Jan 10, 2020
fc94630
try and fix the options to work with new ui
kzahel Jan 10, 2020
2a1b2b2
cleanup and finalize release
kzahel Jan 11, 2020
ad46f1e
update readme
kzahel Jan 11, 2020
d2b87ce
Merge pull request #201 from kzahel/react-ui
kzahel Jan 11, 2020
2465bdf
add makedeps
kzahel Jan 28, 2020
c6e9056
forgot babelrc
kzahel Mar 12, 2020
e658424
Update README.md
kzahel Jul 17, 2020
2652311
forgot babelrc
kzahel Jul 30, 2020
6f156d7
Made https work, altough very unpolished yet
mumme74 Apr 1, 2021
5a57d61
Add .gitignore
mumme74 Apr 2, 2021
f857b20
More changes, got https to work
mumme74 Apr 2, 2021
6f98b47
Added https functionality to GUI
mumme74 Apr 3, 2021
b636f16
Cleanup
mumme74 Apr 3, 2021
a778e67
More cleanup before pull request
mumme74 Apr 3, 2021
3e20c13
Do suggestions from maintainer during pull request.
mumme74 Apr 4, 2021
7ee08df
Merge pull request #260 from mumme74/ssl
kzahel Apr 6, 2021
b91f2aa
Revise README for Chrome Extension transition
kzahel Dec 5, 2025
9300dbe
Update notification link in README.md
kzahel Dec 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
More changes, got https to work
  • Loading branch information
mumme74 committed Apr 2, 2021
commit f857b2057a6a08372e4b44935ec0ebfbb129f7c1
3 changes: 2 additions & 1 deletion makedeps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
"@material-ui/icons": "^4.5.1",
"babel": "^6.23.0",
"browserify": "^16.5.0",
"node-forge": "^0.8.0",
"node-forge": "^0.10.0",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"requirejs": "^2.3.6",
"underscore": "^1.9.1"
}
}
4 changes: 3 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
"minimum_chrome_version": "45",
"app": {
"background": {
"scripts": ["underscore.js","encoding.js","common.js", "assets/bundle.js", "log-full.js","mime.js","buffer.js","request.js","socket.js","stream.js","chromesocketxhr.js","connection.js","webapp.js","websocket.js","handlers.js","httplib.js","upnp.js","background.js"]
"scripts": ["underscore.js","encoding.js","common.js","assets/bundle.js",
"log-full.js", "mime.js", "buffer.js","request.js","socket.js","stream.js", "chromesocketxhr.js",
"connection.js","webapp.js","websocket.js","handlers.js","httplib.js","upnp.js","background.js"]
}
},
"permissions": [
Expand Down
262 changes: 20 additions & 242 deletions socket.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
(function() {


// function to create certificate
var createCert = function(cn, data) {
console.log(
Expand All @@ -22,13 +21,13 @@ var createCert = function(cn, data) {
value: 'SE'
}, {
shortName: 'ST',
value: 'Kronoberg'
value: 'test-st'
}, {
name: 'localityName',
value: 'Växjö'
value: 'test-locality'
}, {
name: 'organizationName',
value: 'Test'
value: 'Testapp'
}, {
shortName: 'OU',
value: 'Test'
Expand Down Expand Up @@ -57,28 +56,29 @@ var createCert = function(cn, data) {
cert.publicKey = keys.publicKey;

// self-sign certificate
cert.sign(keys.privateKey);
cert.sign(keys.privateKey, forge.md.sha256.create());

// save data
data[cn] = {
cert: forge.pki.certificateToPem(cert),
privateKey: forge.pki.privateKeyToPem(keys.privateKey)
};

console.log('certificate created for \"' + cn + '\": \n' + data[cn].cert);
//console.log('certificate created for \"' + cn + '\": \n' + data[cn].cert);
};

var end = {};
var data = {};

// create certificate for server and client
createCert('server', data);
//createCert('client', data);
createCert('client', data);
console.log(data.server.privateKey);
console.log(data.server.cert);

/*

var success = false;
let secret = "My secret message", response, roundtrip;

// create TLS client
end.client = forge.tls.createConnection({
Expand All @@ -99,12 +99,12 @@ end.client = forge.tls.createConnection({
},
connected: function(c) {
console.log('Client connected...');

/*
// send message to server
setTimeout(function() {
c.prepareHeartbeatRequest('heartbeat');
c.prepare('Hello Server');
}, 1);
}, 1);*/
},
getCertificate: function(c, hint) {
console.log('Client getting certificate ...');
Expand All @@ -118,9 +118,9 @@ end.client = forge.tls.createConnection({
end.server.process(c.tlsData.getBytes());
},
dataReady: function(c) {
var response = c.data.getBytes();
console.log('Client received \"' + response + '\"');
success = (response === 'Hello Client');
roundtrip = c.data.getBytes();
console.log('Client received \"' + roundtrip + '\"');
success = (roundtrip === secret);
c.close();
},
heartbeatReceived: function(c, payload) {
Expand Down Expand Up @@ -172,10 +172,11 @@ end.server = forge.tls.createConnection({
end.client.process(c.tlsData.getBytes());
},
dataReady: function(c) {
console.log('Server received \"' + c.data.getBytes() + '\"');
response = c.data.getBytes();
console.log('Server received \"' + response + '\"');

// send response
c.prepare('Hello Client');
c.prepare(response);
c.close();
},
heartbeatReceived: function(c, payload) {
Expand All @@ -189,238 +190,15 @@ end.server = forge.tls.createConnection({
}
});

//console.log('created TLS client and server, doing handshake...');
//end.client.handshake();
console.log('created TLS client and server, doing handshake...');
end.client.handshake();
end.client.prepare(secret);
console.log("sucess:" + success);

//WSC.Tls = {end: end, data: data };
*/




// the Ssl sockets
var string2ArrayBuffer = function(string, callback) {
var buf = new ArrayBuffer(string.length);
var bufView = new Uint8Array(buf);
for (var i=0; i < string.length; i++) {
bufView[i] = string.charCodeAt(i);
}
callback(buf);
};

var arrayBuffer2String = function(buf, callback) {
var bufView = new Uint8Array(buf);
var chunkSize = 65536;
var result = '';
for (var i = 0; i < bufView.length; i += chunkSize) {
result += String.fromCharCode.apply(null, bufView.subarray(i, Math.min(i + chunkSize, bufView.length)));
}
callback(result);
};

var SocketSslTcp = function() {
this._buffer = '';
this._requiredBytes = 0;
this._onReceive = this._onReceive.bind(this);
this._onReceiveError = this._onReceiveError.bind(this);
//chrome.sockets.tcp.apply(this); //net.AbstractTCPSocket.apply(this);
};

//SocketSslTcp.prototype.__proto__ = net.AbstractTCPSocket.prototype;
SocketSslTcp.prototype = Object.create(chrome.sockets.tcp, {constructor: {value: SocketSslTcp}})

/* // implementation in webapp.js
SocketSslTcp.prototype.connect = function(addr, port) {
var _this = this;
this._active();
chrome.sockets.tcp.create({}, function(si) {
_this.socketId = si.socketId;
if (_this.socketId > 0) {
registerSocketConnection(si.socketId);
chrome.sockets.tcp.setPaused(_this.socketId, true);
// Port will be of the form +port# given that it is using SSL.
chrome.sockets.tcp.connect(_this.socketId, addr, parseInt(port.substr(1)),
_this._onConnect.bind(_this));
} else {
_this.emit('error', "Couldn\'t create socket");
}
});
};*/

SocketSslTcp.prototype._onConnect = function(rc) {
if (rc < 0) {
this.emit('error', 'Couldn\'t connect to socket: ' +
chrome.runtime.lastError.message + ' (error ' + (-rc) + ')');
return;
}
this._initializeTls({});
this._tls.handshake(this._tlsOptions.sessionId || null);
chrome.sockets.tcp.onReceive.addListener(this._onReceive);
chrome.sockets.tcp.onReceiveError.addListener(this._onReceiveError);
chrome.sockets.tcp.setPaused(this.socketId, false);
};

SocketSslTcp.prototype._initializeTls = function(options) {
var _this = this;
this._tlsOptions = options;
this._tls = window.forge.tls.createConnection({
server: false,
sessionId: options.sessionId || null,
caStore: options.caStore || [],
sessionCache: options.sessionCache || null,
cipherSuites: options.cipherSuites || [
window.forge.tls.CipherSuites.TLS_RSA_WITH_AES_128_CBC_SHA,
window.forge.tls.CipherSuites.TLS_RSA_WITH_AES_256_CBC_SHA],
virtualHost: options.virtualHost,
verify: options.verify || function() { return true },
getCertificate: options.getCertificate,
getPrivateKey: options.getPrivateKey,
getSignature: options.getSignature,
deflate: options.deflate,
inflate: options.inflate,
connected: function(c) {
// first handshake complete, call handler
// if(c.handshakes === 1) {
console.log('TLS socket connected');
_this.emit('connect');
// }
},
tlsDataReady: function(c) {
// send TLS data over socket
var bytes = c.tlsData.getBytes();
string2ArrayBuffer(bytes, function(data) {
chrome.sockets.tcp.send(_this.socketId, data, function(sendInfo) {
if (sendInfo.resultCode < 0) {
console.error('SOCKET ERROR on write: ' +
chrome.runtime.lastError.message + ' (error ' + (-sendInfo.resultCode) + ')');
}
if (sendInfo.bytesSent === data.byteLength) {
_this.emit('drain');
} else {
if (sendInfo.bytesSent >= 0) {
console.error('Can\'t handle non-complete writes: wrote ' +
sendInfo.bytesSent + ' expected ' + data.byteLength);
}
_this.emit('error', 'Invalid write on socket, code: ' + sendInfo.resultCode);
}
});
});
},
dataReady: function(c) {
// indicate application data is ready
var data = c.data.getBytes();
irc.util.toSocketData(forge.util.decodeUtf8(data), function(data) {
_this.emit('data', data);
});
},
closed: function(c) {
// close socket
_this._close();
},
error: function(c, e) {
// send error, close socket
_this.emit('error', 'tlsError: ' + e.message);
_this._close();
}
});
};

SocketSslTcp.prototype._onClosed = function() {
if (this._tls && this._tls.open && this._tls.handshaking) {
this.emit('error', 'Connection closed during handshake');
}
};

SocketSslTcp.prototype.close = function() {
if (this._tls)
this._tls.close();
};

SocketSslTcp.prototype._close = function() {
if (this.socketId != null) {
chrome.sockets.tcp.onReceive.removeListener(this._onReceive);
chrome.sockets.tcp.onReceiveError.removeListener(this._onReceiveError);
chrome.sockets.tcp.disconnect(this.socketId);
chrome.sockets.tcp.close(this.socketId);
registerSocketConnection(this.socketId, true);
}
this.emit('close');
};

SocketSslTcp.prototype.write = function(data) {
var _this = this;
arrayBuffer2String(data, function(data) {
_this._tls.prepare(data);
});
};

SocketSslTcp.prototype._onReceive = function(receiveInfo) {
if (receiveInfo.socketId != this.socketId)
return;
this._active();
if (!this._tls.open)
return;
var _this = this;
arrayBuffer2String(receiveInfo.data, function (data) {
_this._buffer += data;
if (_this._buffer.length >= _this._requiredBytes) {
_this._requiredBytes = _this._tls.process(_this._buffer);
_this._buffer = '';
}
});
};

SocketSslTcp.prototype._onReceiveError = function (readInfo) {
if (readInfo.socketId != this.socketId)
return;
this._active();
if (info.resultCode === -100) { // connection closed
this.emit('end');
this._close();
}
else {
var message = '';
if (chrome.runtime.lastError)
message = chrome.runtime.lastError.message;
this.emit('error', 'read from socket: ' + message + ' (error ' +
(-readInfo.resultCode) + ')');
this._close();
return;
}
};


// wrapper for socket.tcp
var SocketTcp = function() { }
SocketTcp.prototype = Object.create(chrome.sockets.tcp, {constructor: {value: SocketTcp}});
SocketTcp.prototype.onReceive = {
addListener:function(cb) {
chrome.sockets.tcp.onReceive.addListener(function(){
console.log("SocketTcp.onReceive", arguments);
cb.apply(this, arguments);
});
}
}



var SocketsSingleton = function() { }
SocketsSingleton.prototype = Object.create(chrome.sockets, {constructor: {value: SocketsSingleton}});
SocketsSingleton.prototype.setSsl = function(useSsl) {
if (!useSsl) {
SocketsSingleton.prototype.tcp = new SocketTcp; //chrome.sockets.tcp;
SocketsSingleton.prototype.udp = chrome.sockets.udp;
SocketsSingleton.prototype.tcpServer = chrome.sockets.tcpServer;
} else {
console.warn("Not ready yet");
SocketsSingleton.prototype.tcp = new SocketSslTcp; //chrome.sockets.tcp;
SocketsSingleton.prototype.udp = chrome.sockets.udp;
SocketsSingleton.prototype.tcpServer = chrome.sockets.tcpServer;
}
}

WSC.Sockets = new SocketsSingleton;
WSC.Sockets.setSsl(true);


})();
Expand Down
Loading