-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
86 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
POP3 server written in Node.js. | ||
node-pop3d is a POP3 server written in Node.js. It is aiming to be RFC 1939 compliant and has the following set of features: | ||
|
||
* PAM authentication | ||
* mbox and spool directory support | ||
* simple configuration (via a JSON file) | ||
* extensive logging (file, syslog, stdout) | ||
|
||
Doesn't conform to any RFC. Very much a work in progress, at the moment. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,72 @@ | ||
var net = require("net"); | ||
|
||
var argv = require('optimist') | ||
.usage("Usage: $0 --port [port] --username username --password password --commands command1 command2") | ||
.usage("Usage: $0 --port [port] --username username --password password") | ||
.demand(['port', 'username', 'password']) | ||
.argv; | ||
|
||
state = "username"; | ||
var state = "username"; | ||
var multiline = false; | ||
|
||
socket = net.Socket() | ||
socket.addListener('error', function(data) { | ||
console.log(data); | ||
}); | ||
|
||
socket.addListener('data', function(data) { | ||
|
||
console.log("GOT data: " + data); | ||
console.log("GOT data: '" + data + "'"); | ||
|
||
if (data.substring(data.length-3, 3) === "\n\r\n") | ||
console.log("wooo"); | ||
if (multiline && data.slice(data.length-5).toString() === "\r\n.\r\n") { | ||
multiline = false; | ||
} | ||
|
||
if (state === "username") { | ||
if (!multiline) { | ||
|
||
console.log("USER " + argv.username); | ||
socket.write('USER ' + argv.username + '\r\n'); | ||
state = "password"; | ||
if (state === "username") { | ||
|
||
} else if (state === "password") { | ||
console.log("USER " + argv.username); | ||
socket.write('USER ' + argv.username + '\r\n'); | ||
state = "password"; | ||
|
||
console.log("PASS " + argv.password); | ||
socket.write('PASS ' + argv.password + '\r\n'); | ||
state = "stat"; | ||
} else if (state === "password") { | ||
|
||
} else if (state === "stat") { | ||
console.log("PASS " + argv.password); | ||
socket.write('PASS ' + argv.password + '\r\n'); | ||
state = "noop"; | ||
|
||
console.log("STAT"); | ||
socket.write("STAT\r\n"); | ||
state = "list"; | ||
} else if (state === "noop") { | ||
|
||
} else if (state === "list") { | ||
console.log("NOOP"); | ||
socket.write("NOOP\r\n"); | ||
state = "stat"; | ||
|
||
console.log("LIST"); | ||
socket.write("LIST\r\n"); | ||
state = "noop"; | ||
} else if (state === "stat") { | ||
|
||
} else if (state === "noop") { | ||
console.log("STAT"); | ||
socket.write("STAT\r\n"); | ||
state = "list"; | ||
|
||
console.log("NOOP"); | ||
socket.write("NOOP\r\n"); | ||
state = "retr"; | ||
} else if (state === "list") { | ||
|
||
} else if (state === "retr") { | ||
console.log("LIST"); | ||
socket.write("LIST\r\n"); | ||
state="retr"; | ||
multiline = true; | ||
|
||
console.log("RETR 1"); | ||
socket.write("RETR 1\r\n"); | ||
state = "dele"; | ||
} else if (state === "retr") { | ||
|
||
console.log("RETR 1"); | ||
socket.write("RETR 1\r\n"); | ||
state = "dele"; | ||
multiline = true; | ||
} | ||
} | ||
|
||
|
||
console.log(err); | ||
|
||
}); | ||
|
||
socket.connect(argv.port); | ||
|
||
function send(msg) { | ||
socket.write(msg); | ||
} |