Skip to content

Commit 5aa721b

Browse files
committed
fix test
1 parent 4cc9caa commit 5aa721b

8 files changed

+46
-70
lines changed

config.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
2-
"server": [
3-
"still-tor-8707.herokuapp.com"
4-
],
2+
"server": "127.0.0.1",
53
"local_port": 1080,
4+
"remote_port": 8080,
65
"password": "`try*(^^$some^$%^complex>:<>?~password/",
76
"timeout": 600,
87
"method": "rc4"

local.js

+1-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server.js

+24-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/local.coffee

+1-4
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ options =
1818
string: ['local_address', 'server', 'password',
1919
'config_file', 'method']
2020
default:
21-
'local_address': '127.0.0.1'
22-
'local_port': 1080
23-
'remote_port': 80
2421
'config_file': path.resolve(__dirname, "config.json")
2522

2623
inetNtoa = (buf) ->
@@ -190,5 +187,5 @@ server.listen PORT, LOCAL_ADDRESS, ->
190187
console.log "server listening at", address
191188

192189
server.on "error", (e) ->
193-
console.log "Address in use, aborting" if e.code is "EADDRINUSE"
190+
console.log "address in use, aborting" if e.code is "EADDRINUSE"
194191
process.exit 1

src/server.coffee

+14-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ options =
1919
'm': 'method'
2020
string: ['password', 'method', 'config_file']
2121
default:
22-
'remote_port': process.env.PORT || 8080
23-
'password': process.env.KEY
24-
'method': process.env.METHOD
2522
'config_file': path.resolve(__dirname, "config.json")
2623

2724
inetNtoa = (buf) ->
@@ -31,8 +28,14 @@ configFromArgs = parseArgs process.argv.slice(2), options
3128
configFile = configFromArgs.config_file
3229
configContent = fs.readFileSync(configFile)
3330
config = JSON.parse(configContent)
31+
32+
config['remote_port'] = +process.env.PORT if process.env.PORT
33+
config['password'] = process.env.KEY if process.env.KEY
34+
config['method'] = process.env.METHOD if process.env.METHOD
35+
3436
for k, v of configFromArgs
3537
config[k] = v
38+
3639
timeout = Math.floor(config.timeout * 1000)
3740
PORT = config.remote_port
3841
KEY = config.password
@@ -133,3 +136,11 @@ wss.on "connection", (ws) ->
133136
console.warn "server: #{e}"
134137
console.log "concurrent connections:", wss.clients.length
135138
remote.destroy() if remote
139+
140+
wss.on "listening", (address) ->
141+
address = wss._server.address()
142+
console.log "server listening at", address
143+
144+
wss.on "error", (e) ->
145+
console.log "address in use, aborting" if e.code is "EADDRINUSE"
146+
process.exit 1

src/test.coffee

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ server.stderr.on 'data', (data) ->
6262

6363
local.stdout.on 'data', (data) ->
6464
console.log data.toString()
65-
if data.toString().indexOf('listening at port') >= 0
65+
if data.toString().indexOf('listening at') >= 0
6666
localReady = true
6767
if localReady and serverReady and not curlRunning
6868
runCurl()
6969

7070
server.stdout.on 'data', (data) ->
7171
console.log data.toString()
72-
if data.toString().indexOf('listening at port') >= 0
72+
if data.toString().indexOf('listening at') >= 0
7373
serverReady = true
7474
if localReady and serverReady and not curlRunning
7575
runCurl()

test.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test_http.js

-49
This file was deleted.

0 commit comments

Comments
 (0)