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'
build = (callback) ->
@@ -11,7 +10,7 @@ build = (callback) ->
coffee.stderr.on 'data', (data) ->
process.stderr.write data.toString()
coffee.stdout.on 'data', (data) ->
print data.toString()
console.log data.toString()
coffee.on 'exit', (code) ->
console.log 'build completed'
callback?() if code is 0
@@ -23,7 +22,7 @@ test = (callback) ->
coffee.stderr.on 'data', (data) ->
process.stderr.write data.toString()
coffee.stdout.on 'data', (data) ->
print data.toString()
console.log data.toString()
coffee.on 'exit', (code) ->
callback?() if code is 0
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",
"version": "0.9.6",
"dependencies": {
},
"version": "0.9.7",
"dependencies": {},
"engines": {
"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 = ->
defination =
'-b': 'local_address'
'-l': 'local_port'
'-s': 'server'
'-r': 'remote_port'
'-k': 'password',
'-c': 'config_file',
'-m': 'method'
result = {}
nextIsValue = false
lastKey = null
@@ -20,4 +21,4 @@ exports.parseArgs = ->
nextIsValue = true
result
exports.version = "shadowsocks-heroku v0.9.6"
exports.version = "shadowsocks-heroku v0.9.7"
View
@@ -19,7 +19,6 @@
# SOFTWARE.
crypto = require("crypto")
util = require("util")
merge_sort = require("./merge_sort").merge_sort
int32Max = Math.pow(2, 32)
@@ -28,7 +27,7 @@ cachedTables = {} # password: [encryptTable, decryptTable]
getTable = (key) ->
if cachedTables[key]
return cachedTables[key]
util.log "calculating ciphers"
console.log "calculating ciphers"
table = new Array(256)
decrypt_table = new Array(256)
md5sum = crypto.createHash("md5")
@@ -55,15 +54,15 @@ getTable = (key) ->
result = [table, decrypt_table]
cachedTables[key] = result
result
encrypt = (table, buf) ->
i = 0
while i < buf.length
buf[i] = table[buf[i]]
i++
buf
class Encryptor
constructor: (key, @method) ->
@@ -72,20 +71,20 @@ class Encryptor
@decipher = crypto.createDecipher @method, key
else
[@encryptTable, @decryptTable] = getTable(key)
encrypt: (buf) ->
if @method?
result = new Buffer(@cipher.update(buf.toString('binary')), 'binary')
result
else
encrypt @encryptTable, buf
decrypt: (buf) ->
if @method?
result = new Buffer(@decipher.update(buf.toString('binary')), 'binary')
result
else
encrypt @decryptTable, buf
exports.Encryptor = Encryptor
exports.getTable = getTable
Oops, something went wrong.

0 comments on commit 41cda79

Please sign in to comment.