Compare commits

...

1 Commits

Author SHA1 Message Date
Gabriel Cruz
74ab07d40e chore(autotls): remove tcp,yamux,noise from integration test 2025-07-04 16:29:51 -03:00
3 changed files with 21 additions and 15 deletions

View File

@@ -18,6 +18,7 @@ import
./acme/client,
./utils,
../crypto/crypto,
../transports/tcptransport,
../nameresolving/dnsresolver,
../peeridauth/client,
../peerinfo,
@@ -117,17 +118,19 @@ proc new*(
method setup*(
self: AutotlsService, switch: Switch
): Future[bool] {.async: (raises: [CancelledError]).} =
): Future[bool] {.base, async: (raises: [LPError, CancelledError]).} =
trace "Setting up AutotlsService"
let hasBeenSetup = await procCall Service(self).setup(switch)
if hasBeenSetup:
self.peerInfo = switch.peerInfo
if self.config.ipAddress.isNone():
try:
self.config.ipAddress = Opt.some(getPublicIPAddress())
except AutoTLSError as exc:
error "Failed to get public IP address", err = exc.msg
return false
switch.addTransport(TcpTransport.new(upgrade = Upgrade()))
await switch.startTransports()
self.peerInfo = switch.peerInfo
self.managerFut = self.run(switch)
return hasBeenSetup

View File

@@ -55,7 +55,7 @@ type
connManager*: ConnManager
transports*: seq[Transport]
ms*: MultistreamSelect
acceptFuts: seq[Future[void]]
acceptFuts*: seq[Future[void]]
dialer*: Dial
peerStore*: PeerStore
nameResolver*: NameResolver
@@ -256,7 +256,7 @@ proc upgradeMonitor(
await conn.close()
upgrades.release()
proc accept(s: Switch, transport: Transport) {.async: (raises: []).} =
proc accept*(s: Switch, transport: Transport) {.async: (raises: []).} =
## switch accept loop, ran for every transport
##
@@ -336,14 +336,9 @@ proc stop*(s: Switch) {.public, async: (raises: [CancelledError]).} =
trace "Switch stopped"
proc start*(s: Switch) {.public, async: (raises: [CancelledError, LPError]).} =
## Start listening on every transport
if s.started:
warn "Switch has already been started"
return
debug "starting switch for peer", peerInfo = s.peerInfo
proc startTransports*(
s: Switch
) {.public, async: (raises: [CancelledError, LPError]).} =
var startFuts: seq[Future[void]]
for t in s.transports:
let addrs = s.peerInfo.listenAddrs.filterIt(t.handles(it))
@@ -365,9 +360,20 @@ proc start*(s: Switch) {.public, async: (raises: [CancelledError, LPError]).} =
s.acceptFuts.add(s.accept(t))
s.peerInfo.listenAddrs &= t.addrs
proc start*(s: Switch) {.public, async: (raises: [CancelledError, LPError]).} =
## Start listening on every transport
if s.started:
warn "Switch has already been started"
return
debug "starting switch for peer", peerInfo = s.peerInfo
for service in s.services:
discard await service.setup(s)
await s.startTransports()
await s.peerInfo.update()
await s.ms.start()
s.started = true

View File

@@ -87,14 +87,11 @@ when defined(linux) and defined(amd64):
.new()
.withRng(newRng())
.withAddress(MultiAddress.init("/ip4/0.0.0.0/tcp/0").tryGet())
.withTcpTransport()
.withAutotls(
config = AutotlsConfig.new(
acmeServerURL = parseUri(LetsEncryptURLStaging), renewCheckTime = 1.seconds
)
)
.withYamux()
.withNoise()
.build()
await switch.start()