Skip to content

Commit

Permalink
accept create connection count
Browse files Browse the repository at this point in the history
  • Loading branch information
RadKesvat committed Jun 12, 2023
1 parent 16ff079 commit 7b0f20a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/tunnel.nim
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ proc ssl_connect(con: Connection, ip: string, port: int, sni: string){.async.} =
con.trusted = TrustStatus.yes


proc poolFrame() =
proc poolFrame(count : uint = 0) =
proc create() =
var con = newConnection(address = globals.next_route_addr)
var fut = ssl_connect(con, globals.next_route_addr, globals.next_route_port, globals.final_target_domain)
Expand All @@ -66,7 +66,7 @@ proc poolFrame() =
)

var i = context.outbound.connections.len()
while i.uint32 < globals.pool_size:
while i.uint32 < (if count == 0 :globals.pool_size else: count):
try:
create()
inc i
Expand Down Expand Up @@ -129,7 +129,9 @@ proc processConnection(client: Connection) {.async.} =
poolFrame()
asyncCheck processRemote()
else:

if globals.log_conn_destory: echo &"[createNewCon][Error] left without connection, closes forcefully."
poolFrame(1)
client.close()


Expand Down

0 comments on commit 7b0f20a

Please sign in to comment.