Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
RadKesvat committed Dec 22, 2023
1 parent 2efffed commit c38c99c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
32 changes: 15 additions & 17 deletions src/foreign_server.nim
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ proc processConnection(client: Connection) {.async.} =
data.setLen(data.len() + width)
await remote.reader.readExactly(addr data[0 + width], data.len - width)

if client.closed:
if client.closed :
client = await acquireClientConnection(true)
if client == nil:
if globals.log_conn_error: echo "[Error] [processRemote] [loop]: ", "no client for tcp !"
Expand All @@ -143,9 +143,9 @@ proc processConnection(client: Connection) {.async.} =

await client.twriter.write(data)
if globals.log_data_len: echo &"[processRemote] Sent {data.len()} bytes -> client"

if client.isClosing:
# await client.twriter.finish()
if client.isClosing:
await client.twriter.finish()
client = await acquireClientConnection(true)
if client == nil:
if globals.log_conn_error: echo "[Error] [processRemote] [loop]: ", "no client for tcp !"
Expand Down Expand Up @@ -327,18 +327,16 @@ proc poolController() {.async.} =

await conn.twriter.write(generateFinishHandShakeData(upload))


var initsend: CallbackFunc = proc (arg: pointer){.gcsafe.} =
var len = 3000+rand(globals.random_str.len() - 3000)
let random_start = rand(1500)
let full_len = min((len+random_start), globals.random_str.len() - random_start)
var data = globals.random_str[random_start ..< full_len]
let flag: TransferFlags = {DataFlags.junk}
data.flagForSend(flag)
discard conn.twriter.write(data)
if upload: sleepAsync((globals.connection_rewind-1).int * 1000).addcallback(initsend)


await sleepAsync(200)
if upload:
block initialWriteToOpenBandWidth:
var len = 3000+rand(globals.random_str.len() - 3000)
let random_start = rand(1500)
let full_len = min((len+random_start), globals.random_str.len() - random_start)
var data = globals.random_str[random_start ..< full_len]
let flag: TransferFlags = {DataFlags.junk}
data.flagForSend(flag)
await conn.twriter.write(data)

if upload:
context.up_bounds.add conn
Expand Down Expand Up @@ -392,7 +390,7 @@ proc poolController() {.async.} =
await sleepAsync 1.seconds; dec secs_left
if await watch():
break
if secs_left <= 0:
if secs_left <= 0:
break

proc start*(){.async.} =
Expand Down
4 changes: 2 additions & 2 deletions src/iran_server.nim
Original file line number Diff line number Diff line change
Expand Up @@ -561,8 +561,8 @@ proc start*(){.async.} =
await context.listener_udp.join()
echo "Udp server ended."

trackOldConnections(context.up_bounds, globals.connection_age + 2*globals.connection_rewind)
trackOldConnections(context.dw_bounds, globals.connection_age + 2*globals.connection_rewind)
trackOldConnections(context.up_bounds, globals.connection_age + 2*globals.connection_rewind+9999)
trackOldConnections(context.dw_bounds, globals.connection_age + 2*globals.connection_rewind+9999)


trackDeadConnections(context.user_inbounds, globals.max_idle_timeout.uint, true, globals.max_idle_timeout div 2)
Expand Down

0 comments on commit c38c99c

Please sign in to comment.