Skip to content

Commit

Permalink
初始
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbigmouth committed Jun 19, 2014
0 parents commit 14c81c3
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Auto detect text files and perform LF normalization
* text=auto

# Custom for Visual Studio
*.cs diff=csharp
*.sln merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union

# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
HTTP的跳版網站滿多的,<br />
但bbs的卻頗少,<br />
因此特別用nodejs寫了一個給朋友用,<br />
順便將原始碼丟上github,有興趣的人可以自己架來玩。<br />
<br /><br />
使用方法:<br />
1.安裝<a href="http://nodejs.org/" target="_blank">nodejs</a>。<br />
2.下載檔案。<br />
3.在命令列執行node index.js [PORT]。<br />
4.[PORT]中輸入的是跳板站的port位置,如node index.js 13667。(這邊設成你家公司沒有鎖的port就對了)<br />
5.想要跳板的人透過你架站的ip、port連線進來,便可輸入要連接bbs位置轉接過去。
77 changes: 77 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
var net = require('net')
, server = net.createServer()
;

server.on('connection' ,function(conn) {
var client
, host =
{'host' : 'ptt.cc'
,'port' : '23'
}
, status = 'host'
, endClient =
function() {
//console.log(fromIP + ' already end!');
if (client && typeof client.end === 'function') {
client.end();
}
}
, endConn =
function() {
//console.log(fromIP + ' already end!');
conn.end();
}
, input = ''
, fromIP = conn.remoteAddress
;
//console.log(conn.remoteAddress + ' connect!');
conn.write('Input Connect IP[ptt2.cc]:');
conn.on('close', endClient);
conn.on('end', endClient);
conn.on('error', endClient);
conn.on('timeout', endClient);
conn.on('data', function(d) {
var dJson
, dStr
;
switch (status) {
case 'connected' :
client.write(d);
break;
default:
dJson = d.toJSON();
dStr = d.toString();
conn.write(dStr);
if (dJson.length === 1 && dJson[0] === 13) {
conn.write('\r\n');
if (input) {
host[status] = input;
}
if (status === 'host') {
conn.write('Input Connect Port[23]:');
status = 'port';
}
else if (status === 'port') {
client = net.connect(host);
client.on("data", function(d){
conn.write(d);
});
client.on("close", endConn);
client.on("end", endConn);
client.on("error", endConn);
client.on("timeout", endConn);
status = 'connected';
}
input = '';
}
else {
input += dStr;
}
break;
}
});
});
server.listen(process.argv[2] || 80);
server.on('error', function() {
console.log(arguments);
})

0 comments on commit 14c81c3

Please sign in to comment.