Skip to content

Commit

Permalink
Added remote_port, local_address options.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrluanma committed Dec 25, 2014
1 parent 3d397bb commit 41cda79
Show file tree
Hide file tree
Showing 12 changed files with 88 additions and 86 deletions.
5 changes: 2 additions & 3 deletions Cakefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{print} = require 'util'
{spawn} = require 'child_process'

build = (callback) ->
Expand All @@ -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
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions args.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions encrypt.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 23 additions & 21 deletions local.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion merge_sort.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"name": "shadowsocks-heroku",
"version": "0.9.6",
"dependencies": {
},
"version": "0.9.7",
"dependencies": {},
"engines": {
"node": "0.10.x"
}
Expand Down
12 changes: 6 additions & 6 deletions server.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions src/args.coffee
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -20,4 +21,4 @@ exports.parseArgs = ->
nextIsValue = true
result

exports.version = "shadowsocks-heroku v0.9.6"
exports.version = "shadowsocks-heroku v0.9.7"
13 changes: 6 additions & 7 deletions src/encrypt.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
# SOFTWARE.

crypto = require("crypto")
util = require("util")
merge_sort = require("./merge_sort").merge_sort
int32Max = Math.pow(2, 32)

Expand All @@ -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")
Expand All @@ -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) ->
Expand All @@ -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
Loading

0 comments on commit 41cda79

Please sign in to comment.