Permalink
Browse files

Added `remote_port`, `local_address` options.

  • Loading branch information...
mrluanma committed Dec 25, 2014
1 parent 3d397bb commit 41cda79ec5e85ac726bae7a32cbd56c7ab9f39a4
Showing with 88 additions and 86 deletions.
  1. +2 −3 Cakefile
  2. +4 −2 args.js
  3. +3 −5 encrypt.js
  4. +23 −21 local.js
  5. +1 −1 merge_sort.js
  6. +2 −3 package.json
  7. +6 −6 server.js
  8. +3 −2 src/args.coffee
  9. +6 −7 src/encrypt.coffee
  10. +27 −25 src/local.coffee
  11. +10 −10 src/server.coffee
  12. +1 −1 test.js
View
@@ -1,4 +1,3 @@
{print} = require 'util'
{spawn} = require 'child_process' {spawn} = require 'child_process'
build = (callback) -> build = (callback) ->
@@ -11,7 +10,7 @@ build = (callback) ->
coffee.stderr.on 'data', (data) -> coffee.stderr.on 'data', (data) ->
process.stderr.write data.toString() process.stderr.write data.toString()
coffee.stdout.on 'data', (data) -> coffee.stdout.on 'data', (data) ->
print data.toString() console.log data.toString()
coffee.on 'exit', (code) -> coffee.on 'exit', (code) ->
console.log 'build completed' console.log 'build completed'
callback?() if code is 0 callback?() if code is 0
@@ -23,7 +22,7 @@ test = (callback) ->
coffee.stderr.on 'data', (data) -> coffee.stderr.on 'data', (data) ->
process.stderr.write data.toString() process.stderr.write data.toString()
coffee.stdout.on 'data', (data) -> coffee.stdout.on 'data', (data) ->
print data.toString() console.log data.toString()
coffee.on 'exit', (code) -> coffee.on 'exit', (code) ->
callback?() if code is 0 callback?() if code is 0
process.exit code process.exit code
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -1,8 +1,7 @@
{ {
"name": "shadowsocks-heroku", "name": "shadowsocks-heroku",
"version": "0.9.6", "version": "0.9.7",
"dependencies": { "dependencies": {},
},
"engines": { "engines": {
"node": "0.10.x" "node": "0.10.x"
} }
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -1,13 +1,14 @@
exports.parseArgs = -> exports.parseArgs = ->
defination = defination =
'-b': 'local_address'
'-l': 'local_port' '-l': 'local_port'
'-s': 'server' '-s': 'server'
'-r': 'remote_port'
'-k': 'password', '-k': 'password',
'-c': 'config_file', '-c': 'config_file',
'-m': 'method' '-m': 'method'
result = {} result = {}
nextIsValue = false nextIsValue = false
lastKey = null lastKey = null
@@ -20,4 +21,4 @@ exports.parseArgs = ->
nextIsValue = true nextIsValue = true
result result
exports.version = "shadowsocks-heroku v0.9.6" exports.version = "shadowsocks-heroku v0.9.7"
View
@@ -19,7 +19,6 @@
# SOFTWARE. # SOFTWARE.
crypto = require("crypto") crypto = require("crypto")
util = require("util")
merge_sort = require("./merge_sort").merge_sort merge_sort = require("./merge_sort").merge_sort
int32Max = Math.pow(2, 32) int32Max = Math.pow(2, 32)
@@ -28,7 +27,7 @@ cachedTables = {} # password: [encryptTable, decryptTable]
getTable = (key) -> getTable = (key) ->
if cachedTables[key] if cachedTables[key]
return cachedTables[key] return cachedTables[key]
util.log "calculating ciphers" console.log "calculating ciphers"
table = new Array(256) table = new Array(256)
decrypt_table = new Array(256) decrypt_table = new Array(256)
md5sum = crypto.createHash("md5") md5sum = crypto.createHash("md5")
@@ -55,15 +54,15 @@ getTable = (key) ->
result = [table, decrypt_table] result = [table, decrypt_table]
cachedTables[key] = result cachedTables[key] = result
result result
encrypt = (table, buf) -> encrypt = (table, buf) ->
i = 0 i = 0
while i < buf.length while i < buf.length
buf[i] = table[buf[i]] buf[i] = table[buf[i]]
i++ i++
buf buf
class Encryptor class Encryptor
constructor: (key, @method) -> constructor: (key, @method) ->
@@ -72,20 +71,20 @@ class Encryptor
@decipher = crypto.createDecipher @method, key @decipher = crypto.createDecipher @method, key
else else
[@encryptTable, @decryptTable] = getTable(key) [@encryptTable, @decryptTable] = getTable(key)
encrypt: (buf) -> encrypt: (buf) ->
if @method? if @method?
result = new Buffer(@cipher.update(buf.toString('binary')), 'binary') result = new Buffer(@cipher.update(buf.toString('binary')), 'binary')
result result
else else
encrypt @encryptTable, buf encrypt @encryptTable, buf
decrypt: (buf) -> decrypt: (buf) ->
if @method? if @method?
result = new Buffer(@decipher.update(buf.toString('binary')), 'binary') result = new Buffer(@decipher.update(buf.toString('binary')), 'binary')
result result
else else
encrypt @decryptTable, buf encrypt @decryptTable, buf
exports.Encryptor = Encryptor exports.Encryptor = Encryptor
exports.getTable = getTable exports.getTable = getTable
Oops, something went wrong.

0 comments on commit 41cda79

Please sign in to comment.