Skip to content

Commit

Permalink
Fixer upper.
Browse files Browse the repository at this point in the history
  • Loading branch information
LandonPowell committed May 1, 2017
1 parent 8a9f14c commit 1c82ea7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion client/css/lightChat.css
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ h1, h2, h3, h4, h5, h6 {
#loginMenu hr:after {
content: "or";
background-color: #fff;
color: #aaa;
color: #ddd;
}
#newUserNameSanitized {
font-size: 15px;
Expand Down
10 changes: 8 additions & 2 deletions client/js/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ var parser = {
/* Can you believe that all this was once done with a
* metric fuckton of regex replaces?
*/
var stylizedData = {
htmlString : "",
image : false,
};

// Operators
var operators = {
basic: {
Expand Down Expand Up @@ -81,6 +86,7 @@ var parser = {

function linkHandler(string) { // Fucking regex.
if ( regexEquals(string, /[\w]{1,8}:\/\/[\w\-.]+\/[^\s<]+\.(jpg|gif|svg|png|jpeg)/gi) ) {
stylizedData.image = string;
return "<a href=\""+string+"\" target=\"_blank\"> \
<img class=\"inlineimage\" src=\"/img/"+string+"\"></img>\
</a>";
Expand All @@ -99,7 +105,7 @@ var parser = {
}

// S-Expression Evaluator.
function evaluate(tree) {
function evaluate(tree) {
var operator = tree.shift();
var parsed;

Expand Down Expand Up @@ -152,7 +158,7 @@ var parser = {
return parsed + "</span>";
}

// This returns the result of the evaluation.
// This returns the result of the evaluation.
return evaluate( nest( tokenize( string ) ) ).replace(/ </g, "<");
}
};
Expand Down
21 changes: 11 additions & 10 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ var commands = {
// Simple messages.s
'roomMessage' : {
function(socket, message, roomName) {
addEmit( socket._socket.remoteAddress, socket ); // Room messages count for double usage.
addEmit( socket.ip, socket ); // Room messages count for double usage.

var room = serverData.rooms[roomName];

Expand Down Expand Up @@ -305,7 +305,7 @@ var commands = {
'listRefresh', serverData.roomUsers(socket.rooms[x]).join("\u0004"));
}

moderatorSettings.ipLog[nameSanitize( socket.nick )] = socket._socket.remoteAddress;
moderatorSettings.ipLog[nameSanitize( socket.nick )] = socket.ip;
});
});
},
Expand Down Expand Up @@ -365,7 +365,7 @@ var commands = {
socketServer.roomBroadcast(roomName,
'listRefresh', serverData.roomUsers(roomName).join("\u0004"));

moderatorSettings.ipLog[nameSanitize( socket.nick )] = socket._socket.remoteAddress;
moderatorSettings.ipLog[nameSanitize( socket.nick )] = socket.ip;
}
else {
socket.send(delimit('systemMessage',
Expand Down Expand Up @@ -691,15 +691,16 @@ var commands = {

// RTC server using Web Sockets. Wew lad, we're in the future now.
socketServer.on('connection', function(socket) {
addEmit( socket._socket.remoteAddress, socket );
addEmit( socket.ip, socket );
socket.ip = socket.upgradeReq.headers['x-forwarded-for'] || socket.upgradeReq.connection.remoteAddress;
socket.rooms = [];

// Handles banned users. Basically the asshole bouncer of SeaFour.
if ( ipEmits[socket._socket.remoteAddress] > 12 ||
moderatorSettings.superBanList.indexOf(socket._socket.remoteAddress) + 1 ||
if ( ipEmits[socket.ip] > 12 ||
moderatorSettings.superBanList.indexOf(socket.ip) + 1 ||
collection === undefined ) { // If the collection is undefined, they've joined so quickly the server couldn't even startup.

console.log("Spammer detected at " + socket._socket.remoteAddress);
console.log("Spammer detected at " + socket.ip);
socket.close();

return false;
Expand All @@ -708,10 +709,10 @@ socketServer.on('connection', function(socket) {
// Handlng the more 'front end' aspect of joining.
socket.nick = Math.random().toString(16).substr(2,6);
socket.send(delimit( 'nickRefresh', socket.nick ));
moderatorSettings.ipLog[nameSanitize( socket.nick )] = socket._socket.remoteAddress;
moderatorSettings.ipLog[nameSanitize( socket.nick )] = socket.ip;

socket.on('message', function(data) {
addEmit( socket._socket.remoteAddress, socket );
addEmit( socket.ip, socket );

var parameters = data.split("\u0004");

Expand All @@ -722,7 +723,7 @@ socketServer.on('connection', function(socket) {
return false;
}

if ( moderatorSettings.banList.indexOf( socket._socket.remoteAddress ) + 1 ) { // If the user is banned.
if ( moderatorSettings.banList.indexOf( socket.ip ) + 1 ) { // If the user is banned.
return false;
}

Expand Down

0 comments on commit 1c82ea7

Please sign in to comment.